Troubleshooting SSL Errors
This section contains the most often-cited SSL errors reported by the CAS server and CAS clients in typical CAS integration scenarios.PKIX path building failed
PKIX Example Stack Trace
Sep 28 , 2009 4 : 13 : 26 PM org.jasig.cas.client.validation.AbstractCasProtocolUrlBasedTicketValidator retrieveResponseFromServer SEVERE: 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 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 at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source) at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source) at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source) at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source) at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source) at
org.jasig.cas.client.validation.AbstractCasProtocolUrlBasedTicketValidator.retrieveResponseFromServer(AbstractCasProtocolUrlBasedTicketValidator.java: 35 ) at org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java: 178 ) at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java: 132 ) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java: 235 ) |
If you have multiple java editions installed on your machine, make sure that your app / web server is pointing to the correct jdk/jre version (The one to which the certificate has been exported correctly) One common mistake that occurs while generating self-validated certifcates is that the java_home might be different than that used by the server (especially if it is run within an IDE like Eclipse or Websphere)
No subject alternative names present
Sample Alt Name Stack Trace
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present |
HTTPS hostname wrong
Sample Wrong Host Name Stack Trace
ava.lang.RuntimeException: java.io.IOException: HTTPS hostname wrong: should be <eiger.iad.vt.edu> org.jasig.cas.client.validation.Saml11TicketValidator.retrieveResponseFromServer(Saml11TicketValidator.java: 203 ) org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java: 185 ) org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java: 132 ) org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java: 102 ) |
- CAS client misconfiguration (usually a bad serverName init param)
- Complex multi-tier server environment (e.g. clustered CAS server)
- Host name too broad for scope of wildcard certificate
Wildcard Certificates
JSSE support for wildcard certificates is limited to hosts strictly in the same domain as the wildcard. For example, a certificate with CN=.vt.edu matches hosts *a.vt.edu and b.vt.edu, but not a.b.vt.edu.unrecognized_name Error
JDK unrecognized_name SSL error
javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name |
The above error occurs mainly in Oracle JDK 7 CAS Server installations. In JDK7, SNI
(Server Name Indication) is enabled by default. When the HTTPD Server
does not send the correct Server Name back, the JDK HTTP Connection
refuses to connect and the exception stated above is thrown.
To
fix the issue, you must ensure your HTTPD Server is sending back the
correct hostname. E.g. in Apache HTTPD, you must set the ServerAlias in
the SSL vhost:
Apache HTTPD ServerAlias to fix SNI error
ServerName your.ssl-server.name ServerAlias your.ssl-server.name |
Alternatively, you can disable the
SNI detection in JDK7, by adding this flag to the Java options of your
CAS Servers' application server configuration:
Disable SNI in JDK7
-Djsse.enableSNIExtension= false |
Keystore/TrustStore Reference
Import Trusted Certificate
By default the Java system truststore is at $JAVA_HOME/jre/lib/security/cacerts. The certificate to be imported MUST be a DER-encoded file. If the contents of the certificate file are binary, it's likely DER-encoded; if the file begins with the text---
BEGIN CERTIFICATE
---,
it is PEM-encoded and needs to be converted to DER encoding. The
following example demonstrates a conversion command using OpenSSL.
Convert PEM-encoded Cert to DER Encoding
openssl x509 -in etc/pki/incommon-root-cert.pem -out tmp/incommon-root-cert.der -outform DER |
Keytool Import Command
keytool - import -keystore $JAVA_HOME/jre/lib/security/cacerts -file tmp/incommon-root-cert.der -alias incommon |
List Trusted Certificates
keytool -v -list -keystore $JAVA_HOME/jre/lib/security/cacerts |
Alternatives to Sun keytool Utility
- Portecle is a Java GUI tool that can handle all the keystore and certificate formats I've ever encountered. Very easy to use and recommended if you are uncomfortable with CLI tools.
- keystoreis a CLI tool that has a couple notable improvements on keytool:
- Support for both PEM and DER-encoded files.
- You can import a certificate/key pair directly into a keystore. (With keytool, keys never leave the keystore; you generate them, then a corresponding CSR, then import the matching certificate once it is issued.)
When All Else Fails
If you have read, understood, and tried all the troubleshooting tips on this page and continue to have problems, please perform an SSL trace and attach it to a posting to the cas-user@lists.jasig.org mailing list. An SSL trace is written to STDOUT when the following system property is set,javax.net.debug=ssl
. An example follows of how to do this in the Tomcat servlet container.
Sample setenv.sh Tomcat Script
# Uncomment the next
4
lines
for
custom SSL keystore
# used by all deployed applications
#KEYSTORE=
"$HOME/path/to/custom.keystore"
#CATALINA_OPTS=$CATALINA_OPTS
" -Djavax.net.ssl.keyStore=$KEYSTORE"
#CATALINA_OPTS=$CATALINA_OPTS
" -Djavax.net.ssl.keyStoreType=BKS"
#CATALINA_OPTS=$CATALINA_OPTS
" -Djavax.net.ssl.keyStorePassword=changeit"
# Uncomment the next
4
lines to allow custom SSL trust store
# used by all deployed applications
#TRUSTSTORE=
"$HOME/path/to/custom.truststore"
#CATALINA_OPTS=$CATALINA_OPTS
" -Djavax.net.ssl.trustStore=$TRUSTSTORE"
#CATALINA_OPTS=$CATALINA_OPTS
" -Djavax.net.ssl.trustStoreType=BKS"
#CATALINA_OPTS=$CATALINA_OPTS
" -Djavax.net.ssl.trustStorePassword=changeit"
# Uncomment the next line to print SSL debug trace in catalina.out
#CATALINA_OPTS=$CATALINA_OPTS
" -Djavax.net.debug=ssl"
export CATALINA_OPTS
Aucun commentaire:
Enregistrer un commentaire