|
|
@@ -4,13 +4,10 @@ package org.jeecg.common.nbcbutils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import javax.net.ssl.*;
|
|
|
import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
|
-import java.security.cert.CertificateException;
|
|
|
-import java.security.cert.X509Certificate;
|
|
|
|
|
|
/**
|
|
|
* @Author: zwq
|
|
|
@@ -37,20 +34,6 @@ public class PayNbcbUtils {
|
|
|
try {
|
|
|
URL url = new URL(httpUrl);
|
|
|
|
|
|
- SSLContext sslcontext;
|
|
|
- // 获取一个SSLContext实例 TLSv1.2
|
|
|
- sslcontext = SSLContext.getInstance("SSL", "SunJSSE");
|
|
|
- // 初始化SSLContext实例 由于前置机证书是自颁发的,需要绕开证书校验
|
|
|
- sslcontext.init(null, new TrustManager[]{new MyX509TrustManager()}, new java.security.SecureRandom());
|
|
|
- //由于前置机证书是自颁发的,需要绕开证书校验
|
|
|
- HostnameVerifier ignoreHostnameVerifier = new HostnameVerifier() {
|
|
|
- public boolean verify(String s, SSLSession sslsession) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- };
|
|
|
- HttpsURLConnection.setDefaultHostnameVerifier(ignoreHostnameVerifier);
|
|
|
- HttpsURLConnection.setDefaultSSLSocketFactory(sslcontext.getSocketFactory());
|
|
|
-
|
|
|
// 通过远程url连接对象打开连接
|
|
|
connection = (HttpURLConnection) url.openConnection();
|
|
|
// 设置连接请求方式
|
|
|
@@ -133,24 +116,3 @@ public class PayNbcbUtils {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-class MyX509TrustManager implements X509TrustManager {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
|
|
|
- // TODO Auto-generated method stub
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
|
|
|
- // TODO Auto-generated method stub
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public X509Certificate[] getAcceptedIssuers() {
|
|
|
- // TODO Auto-generated method stub
|
|
|
- return null;
|
|
|
- }
|
|
|
-}
|
|
|
-
|