gpt4 book ai didi

java.security.cert.CertPathValidatorException : Trust anchor for certification path not found

转载 作者:太空宇宙 更新时间:2023-11-03 13:47:22 25 4
gpt4 key购买 nike

我正在尝试打开证书有问题的网站,经过长时间的研究,我找到了通过覆盖 onReceivedSslError 方法传递证书错误的方法,然后继续错误 handler.proceed(); ,但是当我打开网站时出现此异常

 webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
String[] urls = new String[]{url};
new ParseURl().execute(urls);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (!url.equals("about:blank")) {
view.loadUrl(url);
}
return false;
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
});

异常日志

12-26 05:28:11.719 5681-5832/com.example.mina.speechrecognition D/dalvikvm: GC_FOR_ALLOC freed 350K, 13% free 4084K/4652K, paused 7ms, total 8ms
12-26 05:28:12.599 5681-5681/com.example.mina.speechrecognition D/TilesManager: Starting TG #0, 0xb85683a0
12-26 05:28:12.599 5681-5681/com.example.mina.speechrecognition D/TilesManager: new EGLContext from framework: b83b4440
12-26 05:28:12.599 5681-5681/com.example.mina.speechrecognition D/GLWebViewState: Reinit shader
12-26 05:28:13.067 5681-5681/com.example.mina.speechrecognition D/GLWebViewState: Reinit transferQueue
12-26 05:28:13.095 5681-5681/com.example.mina.speechrecognition W/Web Console: The page at https://noor.moe.gov.sa/Noor/login.aspx ran insecure content from http://www.moe.gov.sa/_layouts/15/MOE/script/MOECommon.js.
at null:1
12-26 05:28:18.935 5681-6039/com.example.mina.speechrecognition W/System.err: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
12-26 05:28:18.951 5681-6039/com.example.mina.speechrecognition W/System.err: at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:401)
12-26 05:28:18.951 5681-6039/com.example.mina.speechrecognition W/System.err: at libcore.net.http.HttpConnection.setupSecureSocket(HttpConnection.java:209)
12-26 05:28:18.951 5681-6039/com.example.mina.speechrecognition W/System.err: at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.makeSslConnection(HttpsURLConnectionImpl.java:478)
12-26 05:28:18.951 5681-6039/com.example.mina.speechrecognition W/System.err: at libcore.net.http.HttpsURLConnectionImpl$HttpsEngine.connect(HttpsURLConnectionImpl.java:433)
12-26 05:28:18.951 5681-6039/com.example.mina.speechrecognition W/System.err: at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
12-26 05:28:18.951 5681-6039/com.example.mina.speechrecognition W/System.err: at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
12-26 05:28:19.011 5681-6039/com.example.mina.speechrecognition W/System.err: at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
12-26 05:28:19.011 5681-6039/com.example.mina.speechrecognition W/System.err: at libcore.net.http.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:165)
12-26 05:28:19.011 5681-6039/com.example.mina.speechrecognition W/System.err: at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:449)
12-26 05:28:19.115 5681-6039/com.example.mina.speechrecognition W/System.err: at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:434)
12-26 05:28:19.119 5681-6039/com.example.mina.speechrecognition W/System.err: at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:181)
12-26 05:28:19.123 5681-6039/com.example.mina.speechrecognition W/System.err: at org.jsoup.helper.HttpConnection.get(HttpConnection.java:170)
12-26 05:28:19.123 5681-6039/com.example.mina.speechrecognition W/System.err: at com.example.mina.speechrecognition.WebActivity$ParseURl.doInBackground(WebActivity.java:156)
12-26 05:28:19.123 5681-6039/com.example.mina.speechrecognition W/System.err: at com.example.mina.speechrecognition.WebActivity$ParseURl.doInBackground(WebActivity.java:150)
12-26 05:28:19.123 5681-6039/com.example.mina.speechrecognition W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:287)
12-26 05:28:19.123 5681-6039/com.example.mina.speechrecognition W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:234)
12-26 05:28:19.123 5681-6039/com.example.mina.speechrecognition W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
12-26 05:28:19.123 5681-6039/com.example.mina.speechrecognition W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
12-26 05:28:19.123 5681-6039/com.example.mina.speechrecognition W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
12-26 05:28:19.123 5681-6039/com.example.mina.speechrecognition W/System.err: at java.lang.Thread.run(Thread.java:841)
12-26 05:28:19.123 5681-6039/com.example.mina.speechrecognition W/System.err: Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
12-26 05:28:19.459 5681-6039/com.example.mina.speechrecognition W/System.err: at org.apache.harmony.xnet.provider.jsse.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:282)
12-26 05:28:19.459 5681-6039/com.example.mina.speechrecognition W/System.err: at org.apache.harmony.xnet.provider.jsse.TrustManagerImpl.checkServerTrusted(TrustManagerImpl.java:202)
12-26 05:28:19.463 5681-6039/com.example.mina.speechrecognition W/System.err: at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.verifyCertificateChain(OpenSSLSocketImpl.java:595)
12-26 05:28:19.463 5681-6039/com.example.mina.speechrecognition W/System.err: at org.apache.harmony.xnet.provider.jsse.NativeCrypto.SSL_do_handshake(Native Method)
12-26 05:28:19.463 5681-6039/com.example.mina.speechrecognition W/System.err: at org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:398)
12-26 05:28:19.467 5681-6039/com.example.mina.speechrecognition W/System.err: ... 19 more
12-26 05:28:19.467 5681-6039/com.example.mina.speechrecognition W/System.err: Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
12-26 05:28:19.467 5681-6039/com.example.mina.speechrecognition W/System.err: ... 24 more

我分析网站并提取 ID

public class ParseURl extends AsyncTask<String, Void, Boolean> {
@Override
protected Boolean doInBackground(String... params) {

try {
listID.clear();
Document doc = Jsoup.connect(params[0]).get();
Elements inputs = doc.select("input[type=text], input[type=password], input[type=email]");

for (Element ele : inputs) {
listID.add(ele.attr("id"));
}
} catch (IOException e) {
e.printStackTrace(); // exception fired here
Log.i("error stack", e.getMessage());
}
if (listID.size() > 0) {
return true;
}
return false;
}

@Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);

if (result) {
// Toast.makeText(WebActivity.this, "Analysis site Done", Toast.LENGTH_LONG).show();
//startReadInput();
} else {
Toast.makeText(WebActivity.this, "your site dont have input to fill", Toast.LENGTH_LONG).show();
}
}
}

最佳答案

我已经尝试使用您的 logcat 中显示的网站 url,它有效

final String url = "https://noor.moe.gov.sa/Noor/login.aspx";
WebView mWebView = (WebView) v.findViewById(R.id.webView);
mWebView.setInitialScale(1);
mWebView.getSettings().setUseWideViewPort(true);

mWebView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (!url.equals("about:blank")) {
view.loadUrl(url);
}
return false;
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
});

mWebView.loadUrl(url);

这是截图

BNK's screenshot

关于java.security.cert.CertPathValidatorException : Trust anchor for certification path not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34470527/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com