调用https时握手失败

调用https时握手失败,https,ssl-certificate,postman,keytool,jks,Https,Ssl Certificate,Postman,Keytool,Jks,我需要你在这里帮助我呼叫HTTPS rest服务 一些背景,, 我需要调用以HTTPS托管的rest服务 我拿到了证书,并设法得到了邮递员的回复。 非常重要的是,我只能在邮递员上声明证书为“ca证书”时连接,如果我声明它为“客户端证书”,则无法连接 现在我想通过java调用服务,所以我通过keytool生成JKS: C:\WINDOWS\system32>keytool-import-trustcacerts-alias publickeyfromfromcef-file service.cer

我需要你在这里帮助我呼叫HTTPS rest服务

一些背景,, 我需要调用以HTTPS托管的rest服务

我拿到了证书,并设法得到了邮递员的回复。 非常重要的是,我只能在邮递员上声明证书为“ca证书”时连接,如果我声明它为“客户端证书”,则无法连接

现在我想通过java调用服务,所以我通过keytool生成JKS:

C:\WINDOWS\system32>keytool-import-trustcacerts-alias publickeyfromfromcef-file service.cer-keystore about.jks

我建立了一个客户

System.setProperty("javax.net.ssl.trustStore", "c:/ABCD.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "123456");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

char[] passphrase = "123456".toCharArray(); //password
KeyStore keystore = KeyStore.getInstance("JKS");
//KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keystore.load(new FileInputStream("c:/ABCD.jks"), passphrase); //path

TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keystore);

SSLContext context = SSLContext.getInstance("TLS");
TrustManager[] trustManagers = tmf.getTrustManagers();
context.init(null, trustManagers, null);
SSLSocketFactory sf = context.getSocketFactory();
URL url = new URL("https://services/api/v1/doctors?docId=5555");

HttpsURLConnection httpsCon = (HttpsURLConnection) url.openConnection();
httpsCon.setSSLSocketFactory(sf);
httpsCon.setRequestMethod("GET");

System.out.println("Response Message is " + httpsCon.getResponseMessage());
调用该服务时,我得到错误:java.net.SocketException:Connection resetin method
java.net.SocketInputStream#socketRead

this.exlen =0
我怀疑我没有正确生成jk

以下是调试时的对象状态,我希望它能提供一些启示:

在方法
sun.security.ssl.SSLSocketImpl#performInitialHandshake
中:

this.input.r.helloVersion = LTSv1
this.input.r.getHandshakeHash():mds、sha为空,数据已填充。

方法:
sun.security.ssl.InputRecord#read

this.exlen =0
然后调用
n=socketRead(fd,b,off,length,timeout)时,我在
java.net.SocketInputStream#tRead
上得到一个异常