[英]Client SSL Certificates in Java: PKIX path building failed
我有一个需要客户端证书的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");
但是,现在我通过常规https(没有任何客户端证书)连接的其他Web服务已损坏:
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 webservice?
我为类似的问题尝试了很久,并且正在工作。
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
,也可以实现相同的trustore
。
问题在于证书未正确导入。 我希望下面的链接能对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.