登录 注册
当前位置:主页 > 资源下载 > 48 > org.jasig.cas.client.util.CommonUtils下载

org.jasig.cas.client.util.CommonUtils下载

  • 更新:2024-10-02 23:40:20
  • 大小:19KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:Java - 后端
  • 格式:JAVA

资源介绍

予org.jasig.cas.client.util.CommonUtils 加入 public static void disableSSLVerification(){ try { // Create a trust manager that does not validate certificate chains TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType){} public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType){} } }; // Install the all-trusting trust manager SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); // Create all-trusting host name verifier HostnameVerifier allHostsValid = new HostnameVerifier() { public boolean verify(String hostname, javax.net.ssl.SSLSession session) { return true; } }; // Install the all-trusting host verifier HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (KeyManagementException e) { e.printStackTrace(); } } 並於 openConnection() 之前使用 如 disableSSLVerification(); factory.buildHttpURLConnection(constructedUrl.openConnection());