title: Self signed certificate "doesn' contain CN or DNS subjectAlt"
body: <p>I am working on a project in which my colleague implemented an https server, which uses a self signed server, and I am designing an android app which sends httpposts to it. He has tested it using curl and has no problems. I am using Android 3.2, if it's relevant.</p>
  
  <p>Following this tutorial <a href="http://blog.antoine.li/2010/10/22/android-trusting-ssl-certificates/" rel="nofollow">here</a>, I generated a keystore and added it to the app, also creating a custom httpClient. I replaced the get request with post using the following code:</p>
  
  <pre><code>    private InputStream postHttpConnection(String urlValue,
          JSONObject jsonPost, Context context) {
              InputStream inStream = null;
              URL url;
              try {
                  url = new URL(urlValue);
                  URLConnection conn = url.openConnection();
                  if (!(conn instanceof HttpURLConnection))
                      Log.e("postHttpConnection", "Fail: " + "Not an HTTP connection");
              } catch (MalformedURLException e) {
                  Log.e("postHttpConnection", "Fail: " + e);
              } catch (IOException e) {
                  Log.e("postHttpConnection", "Fail: " + e);
              }
              try {
                  DefaultHttpClient client = new MyHttpClient(context);
                  HttpConnectionParams
                          .setConnectionTimeout(client.getParams(), 10000);
                  HttpResponse postResponse;
                  HttpPost post = new HttpPost(urlValue);
                  StringEntity se = new StringEntity(jsonPost.toString());
                  post.setEntity(se);
                  post.setHeader("Accept", "application/json");
                  post.setHeader("Content-type", "application/json");
                  postResponse = client.execute(post);
                  inStream = postResponse.getEntity().getContent();
              } catch (ClientProtocolException e) {
                  Log.e("postHttpConnection", "Fail: " + e);
              } catch (IOException e) {
                  Log.e("postHttpConnection", "Fail: " + e);
              }
              return inStream;
          }
  </code></pre>
  
  <p>When I use this function, with an appropriate JSONObject, I get the following error:</p>
  
  <pre><code>    E/postHttpConnection(9236): Fail: javax.net.ssl.SSLException: Certificate for &lt;address&gt; doesn't contain CN or DNS subjectAlt
  </code></pre>
  
  <p>Can you tell me what this is related to? Thank you.</p>