简体   繁体   English

X509TrustManager实现不可用htmlunit

[英]No X509TrustManager implementation available htmlunit

For some reason my code with everything imported correctly, using Htmlunit causes an error. 由于某种原因,使用Htmlunit正确导入所有代码的代码会导致错误。

package htmlunittesting;

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
import com.gargoylesoftware.htmlunit.html.HtmlDivision;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

public class httpunittest {

public static void main(String[] args) throws Exception{
    final WebClient webClient = new WebClient();
    final HtmlPage page = webClient.getPage("https://blockchain.info/address/17iyEdbcG3G6RrDHYsi2MzG6RY8vRYvjXm");
    final HtmlDivision div = page.getHtmlElementById("final_balance");
   // final HtmlAnchor anchor = page.getAnchorByName("anchor_name");

    System.out.println(div);

    webClient.closeAllWindows();
}
}

My error is: 我的错误是:

 Caused by: java.security.cert.CertificateException: No X509TrustManager implementation available
at sun.security.ssl.DummyX509TrustManager.checkServerTrusted(Unknown Source)
... 27 more

All I want to do is print out what the final balance is on this test wallet. 我要做的就是打印出此测试钱包的最终余额。

Entire StackTrace as requested: 根据要求整个StackTrace:

Exception in thread "main" javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No X509TrustManager implementation available
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at sun.security.ssl.Handshaker.processLoop(Unknown Source)
at sun.security.ssl.Handshaker.process_record(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:275)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:254)
at com.gargoylesoftware.htmlunit.HtmlUnitSSLConnectionSocketFactory.connectSocket(HtmlUnitSSLConnectionSocketFactory.java:155)
at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:117)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:314)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:178)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1313)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1230)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:338)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:407)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:392)
at htmlunittet.httpunittest.main(httpunittest.java:12)
Caused by: java.security.cert.CertificateException: No X509TrustManager implementation available
at sun.security.ssl.DummyX509TrustManager.checkServerTrusted(Unknown Source)
... 27 more

And yes that is all my code, no other classes. 是的,这就是我的全部代码,没有其他类。

You should add these parameters to java virtual machine: 您应该将以下参数添加到Java虚拟机:

        System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
        System.setProperty("javax.net.ssl.trustStoreType", "JKS");
        System.setProperty("javax.net.ssl.trustStore", "../path/yourtruststore.jks");
        System.setProperty("javax.net.ssl.trustStorePassword", "yourpasswordfortruststore");

If you need Mutual Authentication: 如果需要相互认证:

        System.setProperty("javax.net.ssl.keyStore","../path../yourkeystore.jks");
        System.setProperty("javax.net.ssl.keyStorePassword","yourpasswordforkeystore");
        System.setProperty("javax.net.ssl.keyStoreType", "JKS");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有X509TrustManager实现可用 - No X509TrustManager Implementation available Lucee错误-java.security.cert.CertificateException:没有可用的X509TrustManager实现 - Lucee Error - java.security.cert.CertificateException: No X509TrustManager implementation available javax.net.ssl.SSLHandshakeException:java.security.cert.CertificateException:没有可用的X509TrustManager实现 - javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No X509TrustManager implementation available 尝试连接到Web套接字服务器时,继续获取No X509TrustManager实现可用错误 - Keep getting No X509TrustManager implementation available error when trying to connect to web socket server 通过https“无X509TrustManager实现可用”丢失与Web服务的连接 - Losing connection to a webservice via https “No X509TrustManager implementation available” 接口 X509TrustManager 的不安全实现 - Google Play - Unsafe implementation of the interface X509TrustManager - Google Play 来自 google 的接口 X509TrustManager 的不安全实现 - an unsafe implementation of the interface X509TrustManager from google 实现 X509TrustManager - Implementing X509TrustManager 引起:javax.net.ssl.SSLHandshakeException:java.security.cert.CertificateException:在java(spring)中没有可用的X509TrustManager实现 - Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No X509TrustManager implementation available in java(spring) 如何测试X509TrustManager子类? - How to test X509TrustManager subclass?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM