SunCertPathBuilderException;需要密钥库的JAVA_选项?

SunCertPathBuilderException;需要密钥库的JAVA_选项?,java,ssl,https,keystore,sslhandshakeexception,Java,Ssl,Https,Keystore,Sslhandshakeexception,当通过JavaAPI服务通过https连接到远程服务器时,我遇到了以下异常 sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target 该服务器是Windows server 2

当通过JavaAPI服务通过https连接到远程服务器时,我遇到了以下异常

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
该服务器是Windows server 2012,其相应的通配符证书也作为根证书安装。 我使用keytool将完全相同的证书导入到名为cacerts的密钥库中,因此jvm使用它来防止上述异常。 如keytool所示,证书已正确安装,但连接到服务器时仍会发生握手异常

我检查了服务器上的windows环境变量,发现JAVA_选项缺失。 甚至尝试重新启动整个服务器,但这也没有帮助

为了让它正常工作,我是否需要添加环境变量来手动引用密钥库,如下所示

-Djavax.net.ssl.trustStore=C:\path\to\cacerts

我也可以通过将证书添加到java应用程序密钥库来解决这个问题。

如果它是默认的cacerts文件,则不能。