Search code examples
androidcordovapush-notificationssl-certificateaerogear

Trust anchor for certification path not found error with AeroGear PushPlugin and cordova android platform


I am creating a android application with cordova and AeroGear PushPlugin which uses https for communication with the unified push server.I use a valid CA certification support (TLS1.2) in my server.

When executing with cordova run android return this error in my device :

error javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

knowing, i added the certificat in:

platforms/android/res/raw/myCert.crt

And this tag in the config.xml:

  <platform name="android">
    <network-security-config>
        <base-config cleartextTrafficPermitted="true">
            <trust-anchors>
                <certificates src="myCert.crt" />
            </trust-anchors>
        </base-config>
    </network-security-config>
    </platform>

I followed several solutions proposed but dosen't work for my case.

thanks for Help.


Solution

  • it was certificat generation problem in the UPS widfly server.

    If you have certification authority CA delivered by trsut provider.

    Follow the steps:

    1- You must first convert the PEM certificate delivered by your provider to p12 with this command:

    $ openssl pkcs12 -export -out yourCertificategenerate.p12 -inkey yourCertificatekey.key  -in certifacteDelivedFromProvider.pem -certfile yourCertificateFromProvider.pem // file contains -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE-----)
    

    2- create the local keystore with this commande will be (yourCertificategenerate.jks), and copy it to the standalone/configuration directory with this command:

    $ keytool -importkeystore -deststorepass yourpassword -destkeypass yourpassword -destkeystore yourNewCertificateGenerate.jks -srckeystore yourCertificateGenerate.p12 -srcstoretype PKCS12 -srcstorepass ""
    

    To check the certification chain

    openssl s_client -connect yourDomaine.com -debug
    

    if all things is ok you should have something like this : enter image description here