title: No subject alternative DNS name matching www.billiving.com found. Why this caused and how to solve?
body: <p>I have integration test suite for www.billiving.com API. when that API call endpoint should be <a href="https://www.billiving.com" rel="nofollow">https://www.billiving.com</a>.</p>
  
  <p>my test suite work perfectly on windows. however when it move to ubuntu 14.x it get failed with following exception. [1]</p>
  
  <p>so i have written this [2] code to test it beyond the test suite. still it fail with same exception. </p>
  
  <p>so i tried to import billiving.com certificate to JKS but still it fail with same exception.</p>
  
  <p>i know as a solution we can override the verify method in Verifier class and return as true. but i need proper solution as this can lead security issues.</p>
  
  <p>1) why this error and why its only on linux.</p>
  
  <p>2) how can we solve this with proper solution</p>
  
  <p>API URL:
  <a href="https://www.billiving.com/" rel="nofollow">https://www.billiving.com/</a></p>
  
  <p>[1] exception:</p>
  
  <pre><code>&gt;     javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS
  &gt; name matching www.billiving.com found.    at
  &gt; com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1747)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:241)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:235)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1209)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:135)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:593)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:529)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:943)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1188)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1215)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1199)
  &gt;   at
  &gt; sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434)
  &gt;   at
  &gt; sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
  &gt;   at
  &gt; sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195)
  &gt;   at
  &gt; java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
  &gt;   at
  &gt; sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318)
  &gt;   at Application.main(Application.java:20)  Caused by:
  &gt; java.security.cert.CertificateException: No subject alternative DNS
  &gt; name matching www.billiving.com found.    at
  &gt; sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:193)
  &gt;   at sun.security.util.HostnameChecker.match(HostnameChecker.java:77)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:264)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:250)
  &gt;   at
  &gt; com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1188)
  </code></pre>
  
  <p>[2] sample code :</p>
  
  <pre><code>import java.net.HttpURLConnection;
  import java.net.MalformedURLException;
  import java.net.URL;
  
  public class Application {
  
      public static void main(String[] args) {
  
          URL url;
          try {
              url = new URL(args[0]);
  
          HttpURLConnection connection = (HttpURLConnection) url.openConnection();
          connection.setInstanceFollowRedirects(false);
          connection.setRequestMethod("GET");
  
          if (connection.getResponseCode() &gt;= 400) {
              System.out.println("ERROR "+ connection.getResponseCode());
          } else {
              System.out.println("Success");
          }
  
          System.out.println("Connection Crated");
  
  
  
          } catch (MalformedURLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
      }
  
  
  }
  </code></pre>
  
  <p>command to use above code:</p>
  
  <pre><code>java Application https://www.billiving.com
  </code></pre>