我有一个需要客户端证书的web服务,我在运行时使用以下命令加载:
System.setProperty("javax.net.ssl.keyStore", keystore.getAbsolutePath());
System.setProperty("javax.net.ssl.keyStorePassword", "password");
System.setProperty("javax.net.ssl.keyStoreType", "jks");
System.setProperty("javax.net.ssl.trustStore", cafile.getAbsolutePath());
System.setProperty("javax.net.ssl.trustStorePassword", "password");
然而,现在我的其他webservice通过常规https连接(没有任何客户端证书)被打破了:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
是否有一种方法可以在运行时加载证书而不破坏现有的https web服务?
我很久以前尝试过类似的问题,并且正在工作。
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
Security.addProvider (new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("https.protocols", "SSLv3,TLSv1");
System.setProperty("javax.net.ssl.trustStore", "");
System.setProperty("javax.net.ssl.trustStorePassword", "");
System.setProperty("javax.net.ssl.trustStoreType", "");
Security.ssl.allowUnsafeRenegotiation", "true");
System.setProperty("javax.net.ssl.keyStore", "");
System.setProperty("javax.net.ssl.keyStorePassword", "");
System.setProperty("javax.net.ssl.keyStoreType", "");
System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
同样可以通过在您正在使用的应用服务器中配置trustore
和keystore
来实现。
问题是证书没有正确导入。我希望下面的链接能帮助你。
Link1
Link2