问题描述
我正在尝试编写一个安静的客户端来使用 https 服务。我们正在使用客户端共享的 jks 文件。当我将 jks 文件与soap ui 一起使用时……即将它添加为 sslkeystore,我得到了成功的响应。但是在使用 closeablehttpclient 时,我收到了 401 异常。
代码片段如下
SSLContextbuilder sslBuilder = SSLContexts.custom();
File file = new File(Keystorepass);
SSLBuilder = SSLBuilder.loadTrustMaterial(file,KEYSTOREPASS.toCharArray());
SSLContext sslContext = SSLBuilder.build();
HttpClientBuilder clientBuilder = HttpClients.custom();
clientBuilder.setSSLContext(sslContext);
CloseableHttpClient client = clientBuilder build();
HttpPost httpPost = new HttpPost(url);
HttpEntity entity = new ByteArrayEntity(reqXML.getBytes("UTF-8");
httpPost.setEntity(entity);
response = client.execute(httpPost);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)