title: Java: Ignoring CertificateParsingException
body: <p>I know this kind of questions were asked a lot, but I tried many solutions without help...</p>
  
  <p>I get the following exception information:</p>
  
  <blockquote>
    <p>java.security.cert.CertificateParsingException: X.509 Certificate is
    incomplete: SubjectAlternativeName extension MUST be marked critical
    when subject field is empty</p>
  </blockquote>
  
  <p>This error was brought to the service provider attention and he works now on a solution. </p>
  
  <p>But I need a workaround ASAP.</p>
  
  <p>So far I have tried multiple solutions, for example:</p>
  
  <pre><code>private static SSLContext createSSLContext() {
      try {
          TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
              public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                  return null;
              }
  
              public void checkClientTrusted(X509Certificate[] certs, String authType) {
              }
  
              public void checkServerTrusted(X509Certificate[] certs, String authType) {
              }
          }};
  
          SSLContext context = SSLContext.getInstance("SSL");
          context.init(null, trustAllCerts, new java.security.SecureRandom());
          HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
  
          HostnameVerifier allHostsValid = new HostnameVerifier() {
              public boolean verify(String hostname, SSLSession session) {
                  return true;
              }
          };
  
          HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
          return context;
      } catch (Exception e) {
          LOG.error(e.getMessage(), e);
          throw new HttpClientError(e.toString());
      }
  }
  </code></pre>
  
  <p>But it didn't help and I am really not sure it is relevant.
  But this is one of the solutions to ignore SSL issues.</p>
  
  <p>Let me stress out that my code is for automation tests, so it will not affect production. At least not for now.</p>
  
  <p>How can I ignore this error temporarily and continue my process?</p>
  
  <p>Thanks!</p>