Android Volley selbst signierter HTTPS-Vertrauensanker für Zertifizierungspfad nicht gefunden

Ich bin ein Android-Neuling. Diese Frage wurde schon oft gestellt, aber ich habe fast alle Fragen hier durchgearbeitet.

Ich versuche, ein selbstsigniertes Zertifikat auf Node.Js Server (mit Express) und Volley auf Android zu verwenden.
Using:http: //blog.applegrew.com/2015/04/using-pinned-self-signed-ssl-certificate-with-android-volley

Ich kann nicht @ verwendhttp: //ogrelab.ikratko.com/ using-android-volley-with-self-signed-certificate weil in meiner App zu viel Code zum Ändern vorhanden ist.

Das ist der Fehler.

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Vertrauensanker für Zertifizierungspfad nicht gefunden.

Mein Volleysingelton-Code:

private SSLSocketFactory newSslSocketFactory() {
    try {
        // Get an instance of the Bouncy Castle KeyStore format
        KeyStore trusted = KeyStore.getInstance("BKS");
        // Get the raw resource, which contains the keystore with
        // your trusted certificates (root and any intermediate certs)
        InputStream in = mCtx.getResources().openRawResource(R.raw.evennewer);
        try {
            // Initialize the keystore with the provided trusted certificates
            // Provide the password of the keystore
            trusted.load(in, KEYSTORE_PASSWORD);
        } finally {
            in.close();
        }

        String tmfAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmfAlgorithm);
        tmf.init(trusted);

        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, tmf.getTrustManagers(), null);

        SSLSocketFactory sf = context.getSocketFactory();
        return sf;
    } catch (Exception e) {
        throw new AssertionError(e);
    }
}

Mein Node.Js Code:

var config     = {
  key: fs.readFileSync('./ssl/newkey.key'),
 cert: fs.readFileSync('./ssl/newcert.crt')
};
var port = 443;
var server = https.createServer(config, app).listen(port, function(){
console.log("Express server listening on port " + port);
});

And openssl debug gab zurück:

Überprüfen Sie den Rückkehrcode: 18 (selbstsigniertes Zertifikat)

Antworten auf die Frage(2)

Ihre Antwort auf die Frage