From ee9cb0da4a43bcf523ebb157678f64a2895fba1a Mon Sep 17 00:00:00 2001 From: nickchange <126672920+nickchange@users.noreply.github.com> Date: 星期二, 10 十月 2023 15:30:38 +0800 Subject: [PATCH] 10.10 --- cloud-server-competition/src/main/java/com/dsh/competition/util/httpClinet/HttpClientUtil.java | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cloud-server-competition/src/main/java/com/dsh/competition/util/httpClinet/HttpClientUtil.java b/cloud-server-competition/src/main/java/com/dsh/competition/util/httpClinet/HttpClientUtil.java index 800f58c..bc3969c 100644 --- a/cloud-server-competition/src/main/java/com/dsh/competition/util/httpClinet/HttpClientUtil.java +++ b/cloud-server-competition/src/main/java/com/dsh/competition/util/httpClinet/HttpClientUtil.java @@ -196,14 +196,14 @@ * @return * @throws Exception */ - public String pushHttpsRequsetXml(String url, String xml, Map<String, String> header, String certPassword, String certPath, String certType) throws Exception{ + public static String pushHttpsRequsetXml(String url, String xml, Map<String, String> header, String certPassword, String certPath, String certType) throws Exception{ HttpPost httpPost = new HttpPost(url); for(String key : header.keySet()){ httpPost.setHeader(key, header.get(key)); } httpPost.setHeader("Content-Type", "application/xml"); httpPost.setEntity(new StringEntity(xml, "UTF-8")); - CloseableHttpClient httpCline = this.initCert(certPassword, certPath, certType); + CloseableHttpClient httpCline = initCert(certPassword, certPath, certType); CloseableHttpResponse httpResponse = httpCline.execute(httpPost); String content = null; if(httpResponse.getStatusLine().getStatusCode() == 200){ @@ -211,7 +211,7 @@ }else{ content = "返回状态码:" + httpResponse.getStatusLine() + "。" + EntityUtils.toString(httpResponse.getEntity()); } - this.close(httpResponse); + close(httpResponse); httpCline.close(); return content; } @@ -224,7 +224,7 @@ * @param certType 证书类型 * @throws Exception */ - private CloseableHttpClient initCert(String key, String certPath, String certType) throws Exception { + private static CloseableHttpClient initCert(String key, String certPath, String certType) throws Exception { KeyStore keyStore = KeyStore.getInstance(certType); InputStream inputStream = new FileInputStream(new File(certPath)); try { @@ -234,7 +234,7 @@ } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, key.toCharArray()).build(); SSLConnectionSocketFactory sslsf = - new SSLConnectionSocketFactory(sslcontext, new String[] {"TLSv1"}, null, + new SSLConnectionSocketFactory(sslcontext, null, null, SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } -- Gitblit v1.7.1