title: SSL Certification Issue - Spring and Local Self-Signed Certificate with Tomcat
body: <p>I'm trying to set up a development environment using CAS/Spring, but I'm running into a certificate issue.</p>
  
  <p>UPDATE: Forgot to update this, but this is the error I'm getting now.</p>
  
  <pre><code>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
      org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:328)
      org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:291)
      org.jasig.cas.client.validation.AbstractCasProtocolUrlBasedTicketValidator.retrieveResponseFromServer(AbstractCasProtocolUrlBasedTicketValidator.java:32)
      org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:187)
      org.springframework.security.cas.authentication.CasAuthenticationProvider.authenticateNow(CasAuthenticationProvider.java:140)
      org.springframework.security.cas.authentication.CasAuthenticationProvider.authenticate(CasAuthenticationProvider.java:126)
      org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)
      org.springframework.security.cas.web.CasAuthenticationFilter.attemptAuthentication(CasAuthenticationFilter.java:242)
      org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:195)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
      org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
      org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
      org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
      org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
  </code></pre>
  
  <p>This is my Tomcat server.xml section that deals with my certificate:</p>
  
  <pre><code>&lt;Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" keystoreFile="C:\Users\MyStuff\certs\mykeystore.jks" keystorePass="changeit" truststoreFile="C:\Users\MyStuff\certs\mykeystore.jks" truststorePass="changeit" clientAuth="want" sslProtocol="TLS" ciphers="SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA" /&gt;
  </code></pre>
  
  <p>The only certificate in mykeystore.jks is:</p>
  
  <pre><code>Certificate:
      Data:
          Version: 3 (0x2)
          Serial Number:
              c9:76:d9:5e:50:b3:97:59
          Signature Algorithm: sha256WithRSAEncryption
          Issuer: C=US, ST=DC, L=DC, O=GU, OU=people, CN=www.testthisout.com
          Validity
              Not Before: Mar 12 20:00:22 2015 GMT
              Not After : Mar 11 20:00:22 2025 GMT
          Subject: C=US, ST=DC, L=DC, O=GU, OU=people, CN=www.testthisout.com
          Subject Public Key Info:
              Public Key Algorithm: rsaEncryption
                  Public-Key: (1024 bit)
                  Modulus:
                      00:e7:e7:0b:e7:0f:28:a4:dd:7c:e8:79:51:82:a9:
                      c1:0d:fc:54:ea:63:6f:d0:34:dc:d7:a0:be:a7:90:
                      87:0e:7b:00:96:84:f5:30:70:20:db:8a:e8:22:55:
                      a4:c4:8a:bc:1b:16:08:a9:65:55:19:aa:f9:7c:9e:
                      04:92:73:ed:72:ac:83:76:ae:6d:cd:65:9e:f3:7a:
                      ba:d9:51:29:8f:a9:89:49:b3:b3:31:a9:1b:da:bb:
                      1e:b0:90:2a:6e:d1:1a:42:ff:a6:33:2e:bd:4d:05:
                      b6:af:35:7b:b2:de:eb:69:95:46:67:6a:a9:b6:f1:
                      3a:3b:e2:55:02:1f:8c:85:37
                  Exponent: 65537 (0x10001)
          X509v3 extensions:
              X509v3 Subject Key Identifier:
                  FE:F2:87:D8:2F:1B:25:A4:C1:77:D9:D8:84:C9:D8:F0:3C:F5:15:E2
              X509v3 Authority Key Identifier:
                  keyid:FE:F2:87:D8:2F:1B:25:A4:C1:77:D9:D8:84:C9:D8:F0:3C:F5:15:E
  2
  
              X509v3 Basic Constraints:
                  CA:TRUE
      Signature Algorithm: sha256WithRSAEncryption
          01:da:af:b0:0b:1b:1a:4d:75:5b:af:4f:98:72:04:12:9a:d6:
          47:af:16:49:72:9f:37:ee:71:69:0f:f8:a4:a0:d8:3e:e0:fb:
          87:f4:3d:29:90:46:f6:28:5e:e5:85:e7:af:f4:2c:f4:cb:06:
          7d:ce:2c:74:a7:35:f8:43:da:ec:69:4a:33:47:33:1c:0a:ec:
          5d:1d:7c:93:bd:8f:e5:f9:6d:3d:af:c4:31:47:6d:e7:ae:76:
          c4:c2:64:f2:9e:d5:56:ff:04:59:48:30:f4:25:3f:b7:ab:2a:
          25:12:5c:17:5c:ef:77:1f:b1:64:18:6b:21:02:bf:2a:11:1e:
          ea:e3
  -----BEGIN CERTIFICATE-----
  MIIClDCCAf2gAwIBAgIJAMl22V5Qs5dZMA0GCSqGSIb3DQEBCwUAMGMxCzAJBgNV
  BAYTAlVTMQswCQYDVQQIDAJEQzELMAkGA1UEBwwCREMxCzAJBgNVBAoMAkdVMQ8w
  DQYDVQQLDAZwZW9wbGUxHDAaBgNVBAMME3d3dy50ZXN0dGhpc291dC5jb20wHhcN
  MTUwMzEyMjAwMDIyWhcNMjUwMzExMjAwMDIyWjBjMQswCQYDVQQGEwJVUzELMAkG
  A1UECAwCREMxCzAJBgNVBAcMAkRDMQswCQYDVQQKDAJHVTEPMA0GA1UECwwGcGVv
  cGxlMRwwGgYDVQQDDBN3d3cudGVzdHRoaXNvdXQuY29tMIGfMA0GCSqGSIb3DQEB
  AQUAA4GNADCBiQKBgQDn5wvnDyik3XzoeVGCqcEN/FTqY2/QNNzXoL6nkIcOewCW
  hPUwcCDbiugiVaTEirwbFgipZVUZqvl8ngSSc+1yrIN2rm3NZZ7zerrZUSmPqYlJ
  s7MxqRvaux6wkCpu0RpC/6YzLr1NBbavNXuy3utplUZnaqm28To74lUCH4yFNwID
  AQABo1AwTjAdBgNVHQ4EFgQU/vKH2C8bJaTBd9nYhMnY8Dz1FeIwHwYDVR0jBBgw
  FoAU/vKH2C8bJaTBd9nYhMnY8Dz1FeIwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0B
  AQsFAAOBgQAB2q+wCxsaTXVbr0+YcgQSmtZHrxZJcp837nFpD/ikoNg+4PuH9D0p
  kEb2KF7lheev9Cz0ywZ9zix0pzX4Q9rsaUozRzMcCuxdHXyTvY/l+W09r8QxR23n
  rnbEwmTyntVW/wRZSDD0JT+3qyolElwXXO93H7FkGGshAr8qER7q4w==
  -----END CERTIFICATE-----
  </code></pre>
  
  <p>You can see my CN=www.testthisout.com</p>
  
  <p>So in my hosts file I've added:</p>
  
  <p>127.0.0.1   www.testthisout.com</p>
  
  <p>When I launch go to my Web app (<a href="https://www.testthisout.com:443/CASTest" rel="nofollow">https://www.testthisout.com:443/CASTest</a>), I get the above error. Not sure why it is coming up.</p>
  
  <p>EDIT: Here is CAS's deployerConfigContext.xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encTestg="UTF-8"?&gt;
  &lt;!--
  
      Licensed to Jasig under one or more contributor license
      agreements. See the NOTICE file distributed with this work
      for additional information regarding copyright ownership.
      Jasig licenses this file to you under the Apache License,
      Version 2.0 (the "License"); you may not use this file
      except in compliance with the License.  You may obtain a
      copy of the License at the following location:
  
        http://www.apache.org/licenses/LICENSE-2.0
  
      Unless required by applicable law or agreed to in writing,
      software distributed under the License is distributed on an
      "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
      KIND, either express or implied.  See the License for the
      specific language governing permissions and limitations
      under the License.
  
  --&gt;
  &lt;!--
          | deployerConfigContext.xml centralizes into one file some of the declarative configuration that
          | all CAS deployers will need to modify.
          |
          | This file declares some of the Spring-managed JavaBeans that make up a CAS deployment.
          | The beans declared in this file are instantiated at context initialization time by the Spring
          | ContextLoaderListener declared in web.xml.  It finds this file because this
          | file is among those declared in the context parameter "contextConfigLocation".
          |
          | By far the most common change you will need to make in this file is to change the last bean
          | declaration to replace the default SimpleTestUsernamePasswordAuthenticationHandler with
          | one implementing your approach for authenticating usernames and passwords.
          +--&gt;
  
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:p="http://www.springframework.org/schema/p"
         xmlns:tx="http://www.springframework.org/schema/tx"
         xmlns:sec="http://www.springframework.org/schema/security"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
         http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"&gt;
          &lt;!--
                  | This bean declares our AuthenticationManager.  The CentralAuthenticationService service bean
                  | declared in applicationContext.xml picks up this AuthenticationManager by reference to its id,
                  | "authenticationManager".  Most deployers will be able to use the default AuthenticationManager
                  | implementation and so do not need to change the class of this bean.  We include the whole
                  | AuthenticationManager here in the userConfigContext.xml so that you can see the things you will
                  | need to change in context.
                  +--&gt;
          &lt;bean id="authenticationManager"
                  class="org.jasig.cas.authentication.AuthenticationManagerImpl"&gt;
  
                  &lt;!-- Uncomment the metadata populator to allow clearpass to capture and cache the password
                       This switch effectively will turn on clearpass.
                  &lt;property name="authenticationMetaDataPopulators"&gt;
                     &lt;list&gt;
                        &lt;bean class="org.jasig.cas.extension.clearpass.CacheCredentialsMetaDataPopulator"&gt;
                           &lt;constructor-arg index="0" ref="credentialsCache" /&gt;
                        &lt;/bean&gt;
                     &lt;/list&gt;
                  &lt;/property&gt;
                   --&gt;
  
                  &lt;!--
                          | This is the List of CredentialToPrincipalResolvers that identify what Principal is trying to authenticate.
                          | The AuthenticationManagerImpl considers them in order, finding a CredentialToPrincipalResolver which
                          | supports the presented credentials.
                          |
                          | AuthenticationManagerImpl uses these resolvers for two purposes.  First, it uses them to identify the Principal
                          | attempting to authenticate to CAS /login .  In the default configuration, it is the DefaultCredentialsToPrincipalResolver
                          | that fills this role.  If you are using some other kind of credentials than UsernamePasswordCredentials, you will need to replace
                          | DefaultCredentialsToPrincipalResolver with a CredentialsToPrincipalResolver that supports the credentials you are
                          | using.
                          |
                          | Second, AuthenticationManagerImpl uses these resolvers to identify a service requesting a proxy granting ticket.
                          | In the default configuration, it is the HttpBasedServiceCredentialsToPrincipalResolver that serves this purpose.
                          | You will need to change this list if you are identifying services by something more or other than their callback URL.
                          +--&gt;
                  &lt;property name="credentialsToPrincipalResolvers"&gt;
                          &lt;list&gt;
                                  &lt;!--
                                          | UsernamePasswordCredentialsToPrincipalResolver supports the UsernamePasswordCredentials that we use for /login
                                          | by default and produces SimplePrincipal instances conveying the username from the credentials.
                                          |
                                          | If you've changed your LoginFormAction to use credentials other than UsernamePasswordCredentials then you will also
                                          | need to change this bean declaration (or add additional declarations) to declare a CredentialsToPrincipalResolver that supports the
                                          | Credentials you are using.
                                          +--&gt;
                                  &lt;bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver" &gt;
                                          &lt;property name="attributeRepository" ref="attributeRepository" /&gt;
                                  &lt;/bean&gt;
                                  &lt;!--
                                          | HttpBasedServiceCredentialsToPrincipalResolver supports HttpBasedCredentials.  It supports the CAS 2.0 approach of
                                          | authenticating services by SSL callback, extracting the callback URL from the Credentials and representing it as a
                                          | SimpleService identified by that callback URL.
                                          |
                                          | If you are representing services by something more or other than an HTTPS URL whereat they are able to
                                          | receive a proxy callback, you will need to change this bean declaration (or add additional declarations).
                                          +--&gt;
                                  &lt;bean
                                          class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver" /&gt;
                          &lt;/list&gt;
                  &lt;/property&gt;
  
                  &lt;!--
                          | Whereas CredentialsToPrincipalResolvers identify who it is some Credentials might authenticate,
                          | AuthenticationHandlers actually authenticate credentials.  Here we declare the AuthenticationHandlers that
                          | authenticate the Principals that the CredentialsToPrincipalResolvers identified.  CAS will try these handlers in turn
                          | until it finds one that both supports the Credentials presented and succeeds in authenticating.
                          +--&gt;
                  &lt;property name="authenticationHandlers"&gt;
                          &lt;list&gt;
                                  &lt;!--
                                          | This is the authentication handler that authenticates services by means of callback via SSL, thereby validating
                                          | a server side SSL certificate.
                                          +--&gt;
                                  &lt;bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
                                          p:httpClient-ref="httpClient" /&gt;
                                  &lt;!--
                                          | This is the authentication handler declaration that every CAS deployer will need to change before deploying CAS
                                          | into production.  The default SimpleTestUsernamePasswordAuthenticationHandler authenticates UsernamePasswordCredentials
                                          | where the username equals the password.  You will need to replace this with an AuthenticationHandler that implements your
                                          | local authentication strategy.  You might accomplish this by cTestg a new such handler and declaring
                                          | com.someschool.its.cas.MySpecialHandler here, or you might use one of the handlers provided in the adaptors modules.
                                          +--&gt;
                                  &lt;bean class="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler"&gt;
                                          &lt;property name="filter" value="uid=%u" /&gt;
                                          &lt;property name="searchBase"
                                                  value="ou=people,dc=test,dc=com" /&gt;
                                          &lt;property
                                                  name="contextSource"
                                                  ref="contextSource" /&gt;
                                  &lt;/bean&gt;
  
  
                                  &lt;bean class="org.jasig.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler"&gt;
                                      &lt;property name="tableUsers"&gt;&lt;value&gt;users&lt;/value&gt;&lt;/property&gt;
                                      &lt;property name="fieldUser"&gt;&lt;value&gt;id&lt;/value&gt;&lt;/property&gt;
                                      &lt;property name="fieldPassword"&gt;&lt;value&gt;password&lt;/value&gt;&lt;/property&gt;
                                      &lt;property name="dataSource" ref="dataSource"/&gt;
                                    &lt;/bean&gt;
  
  
  
                          &lt;/list&gt;
                  &lt;/property&gt;
          &lt;/bean&gt;
  
                  &lt;bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource"&gt;
                  &lt;property name="anonymousReadOnly" value="false" /&gt;
                  &lt;property name="pooled" value="true" /&gt;
                  &lt;property name="password" value="50Z1xpUdS64fT18NIz20m3XAy4U" /&gt;
                  &lt;property name="urls"&gt;
                          &lt;list&gt;
                                  &lt;value&gt;ldaps://directory.test.com:636&lt;/value&gt;
                          &lt;/list&gt;
                  &lt;/property&gt;
                  &lt;property name="userDn" value="uid=TestAdmin,ou=Specials,dc=test,dc=com" /&gt;
                  &lt;property name="baseEnvironmentProperties"&gt;
                          &lt;map&gt;
                          &lt;entry&gt;
                          &lt;key&gt;&lt;value&gt;java.naming.security.protocol&lt;/value&gt;&lt;/key&gt;
                          &lt;value&gt;ssl&lt;/value&gt;
                          &lt;/entry&gt;
                                  &lt;entry&gt;
                                          &lt;key&gt;&lt;value&gt;java.naming.security.authentication&lt;/value&gt;&lt;/key&gt;
                                          &lt;value&gt;simple&lt;/value&gt;
                                  &lt;/entry&gt;
                          &lt;/map&gt;
                  &lt;/property&gt;
          &lt;/bean&gt;
  
            &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt;
              &lt;property name="driverClassName"&gt;
                  &lt;value&gt;com.mysql.jdbc.Driver&lt;/value&gt;
              &lt;/property&gt;
              &lt;property name="url"&gt;
                  &lt;value&gt;jdbc:mysql://localhost:3306/user_mgt&lt;/value&gt;
              &lt;/property&gt;
              &lt;property name="username"&gt;&lt;value&gt;root&lt;/value&gt;&lt;/property&gt;
              &lt;property name="password"&gt;&lt;value&gt;apollo&lt;/value&gt;&lt;/property&gt;
          &lt;/bean&gt;
  
          &lt;!--
          This bean defines the security roles for the Services Management application.  Simple deployments can use the in-memory version.
          More robust deployments will want to use another option, such as the Jdbc version.
  
          The name of this should remain "userDetailsService" in order for Spring Security to find it.
           --&gt;
      &lt;!-- &lt;sec:user name="@@THIS SHOULD BE REPLACED@@" password="notused" authorities="ROLE_ADMIN" /&gt;--&gt;
  
      &lt;sec:user-service id="userDetailsService"&gt;
          &lt;sec:user name="@@THIS SHOULD BE REPLACED@@" password="notused" authorities="ROLE_ADMIN" /&gt;
      &lt;/sec:user-service&gt;
  
          &lt;!--
          Bean that defines the attributes that a service may return.  This example uses the Stub/Mock version.  A real implementation
          may go against a database or LDAP server.  The id should remain "attributeRepository" though.
           --&gt;
          &lt;bean id="attributeRepository"
                  class="org.jasig.services.persondir.support.StubPersonAttributeDao"&gt;
                  &lt;property name="backingMap"&gt;
                          &lt;map&gt;
                                  &lt;entry key="uid" value="uid" /&gt;
                                  &lt;entry key="comPersonAffiliation" value="comPersonAffiliation" /&gt;
                                  &lt;entry key="groupMembership" value="groupMembership" /&gt;
                          &lt;/map&gt;
                  &lt;/property&gt;
          &lt;/bean&gt;
  
          &lt;!--
          Sample, in-memory data store for the ServiceRegistry. A real implementation
          would probably want to replace this with the JPA-backed ServiceRegistry DAO
          The name of this bean should remain "serviceRegistryDao".
           --&gt;
          &lt;bean
                  id="serviceRegistryDao"
          class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl"&gt;
              &lt;property name="registeredServices"&gt;
                  &lt;list&gt;
                      &lt;bean class="org.jasig.cas.services.RegexRegisteredService"&gt;
                          &lt;property name="id" value="0" /&gt;
                          &lt;property name="name" value="HTTP and IMAP" /&gt;
                          &lt;property name="description" value="Allows HTTP(S) and IMAP(S) protocols" /&gt;
                          &lt;property name="serviceId" value="^(https?|imaps?)://.*" /&gt;
                          &lt;property name="evaluationOrder" value="10000001" /&gt;
                      &lt;/bean&gt;
                      &lt;!--
                      Use the following definition instead of the above to further restrict access
                      to services within your domain (including subdomains).
                      Note that example.com must be replaced with the domain you wish to permit.
                      --&gt;
                      &lt;!--
                      &lt;bean class="org.jasig.cas.services.RegexRegisteredService"&gt;
                          &lt;property name="id" value="1" /&gt;
                          &lt;property name="name" value="HTTP and IMAP on example.com" /&gt;
                          &lt;property name="description" value="Allows HTTP(S) and IMAP(S) protocols on example.com" /&gt;
                          &lt;property name="serviceId" value="^(https?|imaps?)://([A-Za-z0-9_-]+\.)*example\.com/.*" /&gt;
                          &lt;property name="evaluationOrder" value="0" /&gt;
                      &lt;/bean&gt;
                      --&gt;
                  &lt;/list&gt;
              &lt;/property&gt;
          &lt;/bean&gt;
  
    &lt;bean id="auditTrailManager" class="com.github.inspektr.audit.support.Slf4jLoggingAuditTrailManager" /&gt;
  
    &lt;bean id="healthCheckMonitor" class="org.jasig.cas.monitor.HealthCheckMonitor"&gt;
      &lt;property name="monitors"&gt;
        &lt;list&gt;
          &lt;bean class="org.jasig.cas.monitor.MemoryMonitor"
              p:freeMemoryWarnThreshold="10" /&gt;
          &lt;!--
            NOTE
            The following ticket registries support SessionMonitor:
              * DefaultTicketRegistry
              * JpaTicketRegistry
            Remove this monitor if you use an unsupported registry.
          --&gt;
          &lt;bean class="org.jasig.cas.monitor.SessionMonitor"
              p:ticketRegistry-ref="ticketRegistry"
              p:serviceTicketCountWarnThreshold="5000"
              p:sessionCountWarnThreshold="100000" /&gt;
        &lt;/list&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>EDIT: This </p>