Android KSOAP2 SSL java.security.cert.CertPathValidatorException

Ho provato a connettersi al mio servizio JAX-WS su SSL. Senza SSL tutti funzionano.

Metodo in AsyncTask:

  • Cercando di rilevare il colore blu dall'image utilizzando opencv, e get risultati inaspettati
  • Rimuovere il button "Fatto" di ActionMode
  • Come ricaricare la struttura non gestita libgdx dopo la perdita di context di OpenGL
  • Sostituire frammenti non funziona / sto eseguendo questo il modo giusto?
  • Entrata ricorsiva per eseguire le transactions di pagamento
  • OpenGL + OpenCV aumenta la realtà su Android
  • HttpsTransportSE androidHttpTransport = new HttpsTransportSE("10.0.2.2", 8181, "/Server/?wsdl", 10000); ((HttpsServiceConnectionSE) androidHttpTransport.getServiceConnection()).setSSLSocketFactory(trustAllHosts() .getSocketFactory()); //androidHttpTransport.debug=true; androidHttpTransport.call(getSoapAction(method), envelope); 

    Ottieni SSLContest

     public SSLContext allowAllSSL() { SSLContext context = null; TrustManager[] trustManagers = null; try{ TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); KeyStore keyStore = KeyStore.getInstance("pkcs12"); InputStream in = cntx.getResources().openRawResource(R.raw.client_keystore); try { keyStore.load(in, "password".toCharArray()); } catch (CertificateException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { in.close(); } tmf.init(keyStore); if (trustManagers == null) { trustManagers = new TrustManager[] { new FakeX509TrustManager() }; } try { context = SSLContext.getInstance("SSL"); context.init(null, tmf.getTrustManagers(), new SecureRandom()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }); }catch(Exception ex) { Log.e(TAG,"allowAllSSL failed: "+ex.toString()); } return context; } 

    Ho questo log di errore:

     12-18 07:51:42.161: E/Example:LogOnAsync(3161): doInBackground failed: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 12-18 07:51:42.161: W/System.err(3161): javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. 12-18 07:51:42.169: W/System.err(3161): at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:401) 12-18 07:51:42.169: W/System.err(3161): at libcore.net.http.HttpConnection.setupSecureSocket(HttpConnection.java:209) 12-18 07:51:42.169: W/System.err(3161): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:478) 12-18 07:51:42.169: W/System.err(3161): at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:433) 

  • Due pulsanti di widget Android che chiamano la stessa attività con intenti diversi
  • come visualizzare un'attività automaticamente dopo 5 secondi
  • Carica file con Azure Storage utilizzando SAS (Firma di accesso condiviso)
  • Spinning progress bar in each elemento di listview
  • Errore durante l'analisi dei dati in listview
  • Il runtime di Android ART ha gli stessi limiti di limite di metodo come Dalvik?
  • One Solution collect form web for “Android KSOAP2 SSL java.security.cert.CertPathValidatorException”

    Mi è stato trovato chiedere alla mia domanda: In MainAsync:

      HttpsTransportSE androidHttpTransport = new HttpsTransportSE(10.0.2.2, 8181, "/server/?wsdl", 10000); ((HttpsServiceConnectionSE) androidHttpTransport.getServiceConnection()).setSSLSocketFactory(trustAllHosts().getSocketFactory()); protected SSLContext trustAllHosts() { return allowAllSSL(); } public SSLContext allowAllSSL() { SSLContext context = null; TrustManager[] trustManagers = null; KeyManagerFactory mgrFact; try{ TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); mgrFact = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore keyStore = KeyStore.getInstance("pkcs12"); InputStream in = cntx.getResources().openRawResource(R.raw.keystore); try { keyStore.load(in, "password".toCharArray()); mgrFact.init(keyStore, "password".toCharArray()); } catch (CertificateException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { in.close(); } tmf.init(keyStore); HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { return true; } }); if (trustManagers == null) { trustManagers = new TrustManager[] { new FakeX509TrustManager() }; } final TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { public X509Certificate[] getAcceptedIssuers() { System.out.println("getAcceptedIssuers"); return null; } public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { System.out.println("Сведения о сертификате : " + chain[0].getIssuerX500Principal().getName() + "\n Тип авторизации : " + authType); } public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { System.out.println("checkClientTrusted : " + authType); } } }; //tmf.getTrustManagers() try { context = SSLContext.getInstance("TLS"); context.init(mgrFact.getKeyManagers(), trustAllCerts, new SecureRandom()); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { public boolean verify(String hostname, SSLSession session) { return true; } }); }catch(Exception ex) { Log.e(TAG,"allowAllSSL failed: "+ex.toString()); } return context; } 
    L'Android è un fan Android di Google, tutto su telefoni Android, Android Wear, Android Dev e applicazioni Android Games e così via.