title: Android Verify SSL sertificate
body: <p>I have a little problem with SSL Validation in my application. As I find over internet in FourSquare's documentation they suggest validation like this : <a href="https://stackoverflow.com/questions/3135679/android-httpclient-hostname-in-certificate-didnt-match-example-com-ex">SSL Calidation</a>, but the problem is that I'm using an <code>HttpsURLConnection</code> and I want to use that class instead of <code>DefaultHttpClient</code> . So when I replace client in   <code>getTolerantClient</code> with <code>HttpsURLConnection</code> and try to do this it's showing me some errors : </p>
  
  <pre><code>    public HttpsURLConnection getTolerantClient() {
      HttpsURLConnection client = new HttpsURLConnection();
      SSLSocketFactory sslSocketFactory = (SSLSocketFactory) client.getConnectionManager().getSchemeRegistry().getScheme("https").getSocketFactory();
      final X509HostnameVerifier delegate = sslSocketFactory.getHostnameVerifier();
      if(!(delegate instanceof MyVerifier)) {
          sslSocketFactory.setHostnameVerifier(new MyVerifier(delegate));
      }
      return client;
  }
  </code></pre>
  
  <p>like : </p>
  
  <pre><code>The method getConnectionManager() is undefined for the type HttpsURLConnection
  </code></pre>
  
  <p>&amp; </p>
  
  <p><code>The method getHostnameVerifier() is undefined for the type SSLSocketFactory</code></p>
  
  <p>So any idea how can I use this in my situation?
  Thanks in advance!</p>