今天遇到了一個需求,需要在SSL協定上,執行CAS認證。
但跳出了PKIX的錯誤Exception,當然是因為CAS Client需要接受憑證。
錯誤如下:
java.lang.RuntimeException: 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
於是參考了:
http://stackoverflow.com/questions/9834710/spring-security-and-cas-integration
從Google下載 Java的程式,然後compile執行。
http://code.google.com/p/java-use-examples/source/browse/trunk/src/com/aw/ad/util/InstallCert.java
執行後 InstallCert會將CA憑證導入一個相同目錄下檔案名為jssecacerts的keystore中,只需要把這個檔案複製到JAVA_HOME/lib/security目錄中即可,與原本Cacerts無關。
廣告