10

I have a fresh install of Ubuntu 17.10, on which I installed the package oracle-java8-installer (from PPA).

But when I try to compile an ionic project using "ionic cordova build android", it throws this error:

    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

I am connected to the internet and I tried to:

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

...and also reinstall npm, ionic, java and gradle, all with no success.

edit: I also have ANDROID_HOME and JAVA_HOME exported in .bashrc, and Android Studio installed. I have tried to build the project on a different machine and it works fine. I can't try using OpenJDK because it doesn't work well with Android Studio.

26

Try

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

followed by

sudo apt-get install ca-certificates-java

to get broken cacerts fixed.
For me, this fixed it.
Good luck!

  • Worked for me as well for openjdk-9! Any explanation as to why this works when --reinstall and manually running the postinstall script did not? I'm very interested for future reference. Thanks! – Andy Nov 24 '17 at 1:47
  • 1
    OMG. I've been looking for this answer for weeks. Every other answer to this question I've found did nothing - absolutely nothing. This worked perfectly. Something seems pretty broken with these certs on Ubuntu 17.10. – Dan Nov 30 '17 at 19:21
  • Fixed Jenkins on 17.10 too. Thanks (and upvoted) – Forbesmyester Jan 9 '18 at 15:13
  • Thanks very much worked for me with gradle (4.5.1) and open-jdk-9. Did not work with the oracle-jdk-9 though. – Pabi Feb 7 '18 at 21:35
  • Solution for Ubuntu 18.04. I installed openjdk version 11. Because of Android I had to additionally install openjdk 8. For unknown reason installed cacerts file by openjdk 11 doesn't work with openjdk 8. I had to uninstall both jdks and install only version 8 and then regenerate the cacerts file. – Greg Dan Apr 28 '18 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.