title: PKI Server/CA Subject,Issuer Relation
body: <p>I'm having trouble connecting to a IMAP server using java and keep geeting:</p>
  
  <pre><code>javax.net.ssl.SSLHandshakeException: 
  sun.security.validator.ValidatorException: No trusted certificate found
  at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:298)
  </code></pre>
  
  <p>Using openssl I looked at the certificats and I am confused about the Subject and Issuer parts.</p>
  
  <p>CA-Certificate from the Java certifacte store:</p>
  
  <pre><code>    Issuer: DC=at, DC=XXX, DC=intern, CN=intern-SERVER14-CA
      Validity
          Not Before: Nov 19 13:37:52 2014 GMT
          Not After : Nov 18 13:37:52 2016 GMT
      Subject: C=AT, ST=Vlbg, L=XXX, O=XXX, OU=XXX, CN=outlook.XXX.at
  </code></pre>
  
  <p>Certifcate obtained from the IMAP server using openssl:</p>
  
  <pre><code>Issuer: CN=server14
  Validity
      Not Before: Oct 28 16:18:51 2014 GMT
      Not After : Oct 28 16:18:51 2019 GMT
  Subject: CN=server14
  </code></pre>
  
  <p>Should not at least some of the Subject/Issuer parts match?</p>
  
  <p>Trying <code>openssl verify</code> gives me <code>servercert.pem: /CN=server14
  error 20 at 0 depth lookup:unable to get local issuer certificate</code></p>