title: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
body: <p>Basically, I have a Test server (Linux based) with a public IP bot no public hostname. So I am trying to create ssl certificates for it using IP address. So that my Java application can access another application using the IP address: For example like: </p>
  
  <pre><code>https://210.10.10.10:8443/abc
  </code></pre>
  
  <p>I followed below post:
  <a href="https://stackoverflow.com/questions/8443081/how-are-ssl-certificate-server-names-resolved-can-i-add-alternative-names-using">How are SSL certificate server names resolved/Can I add alternative names using keytool?</a></p>
  
  <p>I did try both the ways as suggested to avoid this exception but non is working. I am getting the same error.</p>
  
  <ol>
  <li><p>I tried Editing the "openssl.cnf" and adding the :</p>
  
  <pre><code> [req]
    req_extensions = v3_req
  
   [ v3_req ]
  
    # Extensions to add to a certificate request
    subjectAltName=IP:210.10.10.10
    # or subjectAltName=DNS:www.example.com
  
    basicConstraints = CA:FALSE
    keyUsage = nonRepudiation, digitalSignature, keyEncipherment
  </code></pre></li>
  </ol>
  
  <p>2.
  And also tried Using the Java 1.7 keytool:</p>
  
  <p>Like creating (Created in windows having java 1.7 and copied all certs and jks files to Linx server env, running on java 1.6) :</p>
  
  <pre><code>    keytool -importkeystore -deststorepass changeit -destkeypass changeit -destkeystore myServerKeystore2.jks -srckeystore serverCertAsPK12.p12  -srcstoretype PKCS12 -alias servercertificate -ext SAN=ip:210.10.10.10
  </code></pre>
  
  <p>I have my environment setup is like below :
  Server is Linux (CentOS), Tomcat 6, JDK 1.6, Application is JAVA application
  Used Openssl to create all certificates and JKS</p>
  
  <p>Still Getting  java.security.cert.CertificateException: No subject alternative names  Exception.</p>
  
  <p>Then I tried to create the JKS files and imported into default javastore file (cacerts) using the keytool (in Java 1.7 env) on windows machine and exported these JKS and cacert file to Linux server.</p>
  
  <p>Then also Still Getting  java.security.cert.CertificateException: No subject alternative names  Exception.</p>
  
  <p>------- Updated below on 19 June on reply to Bruno ---------</p>
  
  <p>Below is my tomcat server.xml settings :</p>
  
  <pre><code>&lt;Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
             maxThreads="150" scheme="https" secure="true"
             truststoreFile="/usr/local/apache-tomcat-6.0.37/conf/cacerts.jks" truststorePass="changeit"
             keystoreFile="/usr/local/apache-tomcat-6.0.37/conf/myServerKeystore2.jks" keystorePass="changeit"
             clientAuth="false" sslProtocol="TLS" /&gt;
  </code></pre>
  
  <p>Where "cacerts.jks" is my client keystore file and "myServerKeystore2.jks" is my server keystore file.</p>
  
  <p>I have followed each step on <a href="http://java-with-shiva.blogspot.in/2013/05/configuring-installing-ssl-https-on.html" rel="nofollow noreferrer">this tutorial</a> to create ssl certificates using openssl.</p>
  
  <p>Please help.</p>