Ubuntu 17.10 Java 8证书错误


10

我重新安装了Ubuntu 17.10,并在其中安装了oracle-java8-installer软件包(来自PPA)。

但是,当我尝试使用“ ionic cordova build android”编译一个离子项目时,会引发以下错误:

    Exception in thread "main" 
    javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1916)
        at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1899)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1420)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
        at org.gradle.wrapper.Download.downloadInternal(Download.java:60)
        at org.gradle.wrapper.Download.download(Download.java:45)
        at org.gradle.wrapper.Install$1.call(Install.java:62)
        at org.gradle.wrapper.Install$1.call(Install.java:48)
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
        at org.gradle.wrapper.Install.createDist(Install.java:48)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
    Caused by: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
        at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:91)
        at sun.security.validator.Validator.getInstance(Validator.java:179)
        at sun.security.ssl.X509TrustManagerImpl.getValidator(X509TrustManagerImpl.java:312)
        at sun.security.ssl.X509TrustManagerImpl.checkTrustedInit(X509TrustManagerImpl.java:171)
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:184)
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1496)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
        ... 14 more
    Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
        at java.security.cert.PKIXParameters.setTrustAnchors(PKIXParameters.java:200)
        at java.security.cert.PKIXParameters.<init>(PKIXParameters.java:120)
        at java.security.cert.PKIXBuilderParameters.<init>
    (PKIXBuilderParameters.java:104)
        at sun.security.validator.PKIXValidator.<init>(PKIXValidator.java:89)
        ... 26 more

我已连接到互联网,并尝试:

$ sudo update-ca-certificates -f
$ sudo apt install --reinstall ca-certificates-java

...并重新安装npm,ionic,java和gradle,所有操作均未成功。

编辑:我也有在.bashrc中导出的ANDROID_HOME和JAVA_HOME,并安装了Android Studio。我试图在另一台机器上构建项目,并且工作正常。我无法尝试使用OpenJDK,因为它无法在Android Studio中正常工作。

Answers:


26

尝试

sudo dpkg --purge --force-depends ca-certificates-java

其次是

sudo apt-get install ca-certificates-java

修复损坏的证书。
对我来说,这解决了它。
祝好运!


也为openjdk-9为我工作!关于为何在--reinstall手动运行后安装脚本时不起作用的任何解释?我对将来的参考非常感兴趣。谢谢!
安迪

1
我的天啊。我已经在寻找这个答案好几个星期了。我找到的这个问题的其他答案都没有做-绝对没有做。这工作得很好。这些证书在Ubuntu 17.10上似乎有些破损。
丹·丹(Dan

詹金斯也固定在17.10。谢谢(和支持)
Forbesmyester

非常感谢gradle(4.5.1)和open-jdk-9为我工作。虽然不适用于oracle-jdk-9。
帕比

Ubuntu 18.04的解决方案。我安装了openjdk版本11。由于Android,我必须另外安装openjdk8。由于未知原因,openjdk 11安装的cacerts文件不适用于openjdk8。我必须卸载两个jdks,仅安装版本8,然后重新生成cacerts。文件。
格雷格·丹
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.