我得到了" javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:未找到证书路径的信任锚。"我的Android应用程序上的异常仅适用于Verizon无线设备。所有通过WiFi的设备,以及通过AT& T,T-Mobile和Sprint网络的3G / 4G连接都可以正常工作。有关VZW的不同之处或如何解决这个问题的任何想法?代码遵循异常。谢谢!
08-05 00:04:27.904: W/System.err(7752): javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
08-05 00:04:27.914: W/System.err(7752): at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:409)
08-05 00:04:27.914: W/System.err(7752): at com.android.okhttp.Connection.upgradeToTls(Connection.java:146)
08-05 00:04:27.924: W/System.err(7752): at com.android.okhttp.Connection.connect(Connection.java:107)
08-05 00:04:27.924: W/System.err(7752): at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:294)
08-05 00:04:27.924: W/System.err(7752): at com.android.okhttp.internal.http.HttpEngine.sendSocketRequest(HttpEngine.java:255)
08-05 00:04:27.934: W/System.err(7752): at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:206)
08-05 00:04:27.934: W/System.err(7752): at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
08-05 00:04:27.934: W/System.err(7752): at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:89)
08-05 00:04:27.944: W/System.err(7752): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197)
08-05 00:04:27.944: W/System.err(7752): at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:254)
08-05 00:04:27.954: W/System.err(7752): at com.spt4u.dnstest.MainActivity.DoDNSTest(MainActivity.java:123)
08-05 00:04:27.954: W/System.err(7752): at com.spt4u.dnstest.MainActivity$1$1.run(MainActivity.java:46)
08-05 00:04:27.954: W/System.err(7752): at java.lang.Thread.run(Thread.java:841)
08-05 00:04:27.954: W/System.err(7752): Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
08-05 00:04:27.964: W/System.err(7752): at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:282)
08-05 00:04:27.964: W/System.err(7752): at com.android.org.conscrypt.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:202)
08-05 00:04:27.964: W/System.err(7752): at com.android.org.conscrypt.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:611)
08-05 00:04:27.964: W/System.err(7752): at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
08-05 00:04:27.964: W/System.err(7752): at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:405)
08-05 00:04:27.964: W/System.err(7752): ... 12 more
08-05 00:04:27.964: W/System.err(7752): Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
08-05 00:04:27.964: W/System.err(7752): ... 17 more
08-05 00:04:59.315: W/ActivityThread(8163): Application com.spt4u.dnstest is waiting for the debugger on port 8100...
public void DoDNSTest()
{
URL u;
int readCharacters = 0;
String retVal = "";
char[] buffer = new char[4096];
String postData= "_method=POST&data[username]=blah&data[password]=pass&data[device_uuid]=8675309";
try {
u = new URL("https://myurl.com/login");
HttpsURLConnection htc = (HttpsURLConnection) u.openConnection();
htc.setUseCaches(false);
htc.setDoInput(true);
htc.setDoOutput(true);
htc.setRequestMethod("POST");
htc.setRequestProperty("User-Agent", "IntelliVan");
htc.setRequestProperty("Connection","close");
htc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
OutputStreamWriter wr = new OutputStreamWriter(htc.getOutputStream());
wr.write(postData);
wr.flush();
BufferedReader rd = new BufferedReader(new InputStreamReader(htc.getInputStream()));
while(readCharacters>-1)
{
readCharacters = rd.read(buffer);
if(readCharacters>0)
{
char[] temp = new char[readCharacters];
System.arraycopy(buffer, 0, temp, 0, readCharacters);
retVal+= new String(temp);
}
}
rd.close();
}
catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}