如何在java.library.path中解决没有conscrypt_openjdk_jni的错误?

时间:2017-08-02 04:14:54

标签: android compiler-errors apk linker-errors sign

我想签署我的apk,所以我执行了以下命令:

  

java -jar signapk.jar platform.x509.pem platform.pk8 app-debug.apk   〜/桌面/ test.apk

但我收到以下错误:

  

线程“main”中的异常java.lang.UnsatisfiedLinkError:no   在java.library.path中的conscrypt_openjdk_jni   java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)at   java.lang.Runtime.loadLibrary0(Runtime.java:870)at   java.lang.System.loadLibrary(System.java:1122)at   org.conscrypt.NativeCryptoJni.init(NativeCryptoJni.java:25)at   org.conscrypt.NativeCrypto。(NativeCrypto.java:54)at   org.conscrypt.OpenSSLBIOInputStream。(OpenSSLBIOInputStream.java:34)     在   org.conscrypt.OpenSSLX509Certificate.fromX509PemInputStream(OpenSSLX509Certificate.java:119)     在   org.conscrypt.OpenSSLX509CertificateFactory $ 1.fromX509PemInputStream(OpenSSLX509CertificateFactory.java:220)     在   org.conscrypt.OpenSSLX509CertificateFactory $ 1.fromX509PemInputStream(OpenSSLX509CertificateFactory.java:216)     在   org.conscrypt.OpenSSLX509CertificateFactory $ Parser.generateItem(OpenSSLX509CertificateFactory.java:94)     在   org.conscrypt.OpenSSLX509CertificateFactory.engineGenerateCertificate(OpenSSLX509CertificateFactory.java:272)     在   java.security.cert.CertificateFactory.generateCertificate(CertificateFactory.java:339)     在com.android.signapk.SignApk.readPublicKey(SignApk.java:182)at   com.android.signapk.SignApk.main(SignApk.java:1087)

如何解决此错误?

(openjdk version“1.8.0_141” OpenJDK运行时环境(版本1.8.0_141-8u141-b15-3~14.04-b15) OpenJDK 64位服务器VM(内置25.141-b15,混合模式) )

2 个答案:

答案 0 :(得分:9)

java -Xmx2048m -Djava.library.path="out/host/linux-x86/lib64" \
    -jar out/host/linux-x86/framework/signapk.jar \
    -w build/target/product/security/platform.x509.pem \
    build/target/product/security/platform.pk8 \
    FileNeedSign.apk FileNeedSign_Signed.apk

答案 1 :(得分:0)

我正在使用Jetty,Kotlin,Java 8和Maven。我的解决方案是双重的。首先在pom.xml中,添加Conscrypt:

<dependency>
    <groupId>org.conscrypt</groupId>
    <artifactId>conscrypt-openjdk</artifactId>
    <version>2.2.1</version>
    <classifier>linux-x86_64</classifier>
</dependency>

请注意<classifier>,它必须适合您的操作系统。从此处的列表中选择一个:https://github.com/google/conscrypt/

我喜欢将配置正确地放在代码中。如果你愿意的话,发火我。我按照这里的说明进行操作:https://www.eclipse.org/jetty/documentation/current/configuring-ssl.html#conscrypt因此,在设置Jetty的sslContextFactory之前,我必须添加:

    Security.addProvider(OpenSSLProvider())

之后:

    // SSLv2Hello and SSLv3 are outdated and insecure.
    // TLSv1.3 works with Conscrypt, but not Java 8!
    sslContextFactory.setExcludeProtocols("SSLv2Hello", "SSLv3", "TLSv1.3")
    sslContextFactory.provider = "Conscrypt"

我想这就是清除它的方法。我今天做了很多更改。

我有一个单独的问题,那就是我的本地主机SSL证书无效。我从以下内容开始:Can you use a service worker with a self-signed certificate?,但最终从服务器获取证书并编辑我的/ etc / hosts文件以使localhost看起来像该服务器。