title: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated when trying to session.getPeerCertificateChain()
body: <p>I am pretty new to working with http/certs/etc.  I have my own hostnameVerifier set up for an apache httpclient. <em>(Trying to allow FQDN to not match as long as cert FQDN is still internal to our domain - not the best I know - but better than nothing)</em></p>
  
  <p>It works fine for most of the servers I have tested with, but there are a couple where I get </p>
  
  <pre><code>javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
  </code></pre>
  
  <p>when I try to </p>
  
  <pre><code>session.getPeerCertificateChain().
  </code></pre>
  
  <p>I am able to view the certificate just fine when I go to the same link in firefox.  </p>
  
  <p>Below is the full code for the method. </p>
  
  <pre><code>@Override
  public void verify( String arg0, SSLSocket arg1 ) throws IOException
  {
      String certFQDN = null;
  
      SSLSession session = arg1.getSession();
      javax.security.cert.X509Certificate[] certs = session.getPeerCertificateChain();
      if ( certs.length &gt; 0 )
      {
          String name = certs[ 0 ].getSubjectDN().getName();
          for ( String s : name.split( "," ) )
          {
              String part[] = s.split( "=" );
              if ( part[ 0 ].trim().equals( "CN" ) )
              {
                  certFQDN = part[ 1 ].trim();
              }
          }
      }
      else
      {
          throw new IOException( "Could not find certificate chain." );
      }
  
  
      if ( !certFQDN.substring( certFQDN.length() - 11 ).equals( ".domain.com" ) )
      {
          throw new SSLException( "Not an internal host: " + certFQDN );
      }
  }
  </code></pre>