经过一些旧的stackoverflow问题的搜索和拖延之后,我在先前提出的SO问题中找到了一个解决方案:
- 问题:通过HTTPS / SSL的Java客户端证书
这是我最终使用的代码。
// Create a trust manager that does not validate certificate chainsTrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){return null;} public void checkClientTrusted(X509Certificate[] certs, String authType){} public void checkServerTrusted(X509Certificate[] certs, String authType){}}};// Install the all-trusting trust managertry { SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, trustAllCerts, new SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());} catch (Exception e) { ;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)