Pre Requisites for CAS
Now before going on to the discussion on Custom Credential To Principal Resolver which requires attribute Repository for fetching user attributes from the underlying repository, In this post I will take up the issue of configuring CAS to use over HTTPS.
While configuring CAS over Https I faced the exception
Error 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.
Though I have configured custom HostNameverifier still I was facing the above error.
The reason behind the above error i found out is that the certificate which i was using was not added to the truststore.
This issue can be resolved with the following steps:
1) Locate the cacerts file from the JDK, which the server is using.
The usual path is jdk1.6.0_05\jre\lib\security\cacerts
2) Run the following command from the command promt:
keytool -list -v -keystore /path/to/cacerts > java_cacerts.txt
Enter keystore password: changeit
In this example, /path/to/cacerts is the location of your cacerts file, and the output of the command will be saved in java_cacerts.txt.
Take a look at java_cacerts.txt. See if it includes the same certificate that is present in the browser by searching for a matching serial number. In the java_cacerts.txt file, the serial number will be in lowercase and without the ":" colon character. If it is not present, then this could be the reason for the error, and we can fix this by adding the certificate found in the browser.
3) Back in the browser, export the Root CA. Choose the "X.509 Certificate (DER)" type, so the exported file has a der extension.
Assuming the file is called example.der, pick the alias 'example' for this certificate.
4) Next import the file.
keytool -import -alias example -keystore /path/to/cacerts -file example.derYou will be prompted for a password, use 'changeit'
and response "yes" on whether to trust this key.
5) Dump the contents again to verify it contains your new certificate(By checking the Serial number). Restart the JVM and check that it can now access the HTTPS URL. Also remove the java_cacerts.txt dump file.
While configuring CAS over Https I faced the exception
Error 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.
Though I have configured custom HostNameverifier still I was facing the above error.
The reason behind the above error i found out is that the certificate which i was using was not added to the truststore.
This issue can be resolved with the following steps:
1) Locate the cacerts file from the JDK, which the server is using.
The usual path is jdk1.6.0_05\jre\lib\security\cacerts
2) Run the following command from the command promt:
keytool -list -v -keystore /path/to/cacerts > java_cacerts.txt
Enter keystore password: changeit
In this example, /path/to/cacerts is the location of your cacerts file, and the output of the command will be saved in java_cacerts.txt.
Take a look at java_cacerts.txt. See if it includes the same certificate that is present in the browser by searching for a matching serial number. In the java_cacerts.txt file, the serial number will be in lowercase and without the ":" colon character. If it is not present, then this could be the reason for the error, and we can fix this by adding the certificate found in the browser.
3) Back in the browser, export the Root CA. Choose the "X.509 Certificate (DER)" type, so the exported file has a der extension.
Assuming the file is called example.der, pick the alias 'example' for this certificate.
4) Next import the file.
keytool -import -alias example -keystore /path/to/cacerts -file example.derYou will be prompted for a password, use 'changeit'
and response "yes" on whether to trust this key.
5) Dump the contents again to verify it contains your new certificate(By checking the Serial number). Restart the JVM and check that it can now access the HTTPS URL. Also remove the java_cacerts.txt dump file.
Comments
Post a Comment