iOS 9.3 : An SSL error has occurred and a secure connection to the server cannot be made
<p>I am getting following error with self signed certificate</p>

<blockquote>
  <p>Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred
  and a secure connection to the server cannot be made.</p>
</blockquote>

<p>while testing web-services for one of my demo app with</p>

<ul>
<li>iOS 9.3</li>
<li>XCode 7.3</li>
<li>Swift 2.2</li>
<li>Alamofire 3.3.0</li>
<li>and Local server : <a href="https://filename.hostname.net" rel="noreferrer">https://filename.hostname.net</a></li>
</ul>

<p><strong>Note:</strong> <em>before assuming its Duplicate, I would request please read it all the way,even same i have reported to apple dev forums</em></p>

<p>Using <strong>Alamofire Library</strong></p>

<hr>

<pre><code>func testAlamofireGETRequest() -&gt; Void
    {
        Alamofire.request(.GET, "https://filename.hostname.net/HelloWeb/service/greeting/john")
            .responseJSON
        { response in
            print("Response JSON: \(response.result.value)")
        }
}
</code></pre>

<hr>

<p>Using <strong>NSURLSession</strong></p>

<hr>

<pre><code>func testNSURLSessionRequest() -&gt; Void {

        let session = NSURLSession.sharedSession()
        let urlString = "https://filename.hostname.net/HelloWeb/service/greeting/john"
        let url = NSURL(string: urlString)
        let request = NSURLRequest(URL: url!)
        let dataTask = session.dataTaskWithRequest(request) { (data:NSData?, response:NSURLResponse?, error:NSError?) -&gt; Void in
            print("done, error: \(error)")

            //Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made.
        }
        dataTask.resume()
    }
</code></pre>

<hr>

<blockquote>
  <p>I spent 2 days with no luck :(</p>
  
  <p>there are bunch of questions already posted but nothing worked for me</p>
</blockquote>

<ul>
<li><a href="https://stackoverflow.com/questions/31254725/transport-security-has-blocked-a-cleartext-http">Transport Security has Blocked a cleartext HTTP</a></li>
<li><a href="https://stackoverflow.com/questions/32755674/ios9-getting-error-an-ssl-error-has-occurred-and-a-secure-connection-to-the-ser">iOS9 getting error “an ssl error has occurred and a secure connection to the server cannot be made”</a></li>
<li><a href="https://stackoverflow.com/questions/30731785/how-do-i-load-an-http-url-with-app-transport-security-enabled-in-ios-9/30732693#30732693">How do I load an HTTP URL with App Transport Security enabled in iOS 9? [duplicate]</a></li>
<li><a href="https://stackoverflow.com/questions/30720813/cfnetwork-sslhandshake-failed-ios-9">CFNetwork SSLHandshake failed iOS 9</a></li>
<li><a href="https://stackoverflow.com/questions/19922717/how-to-handle-cfnetwork-sslhandshake-failed-in-ios">How to handle “CFNetwork SSLHandshake failed” in iOS</a></li>
<li><a href="https://stackoverflow.com/questions/32583303/making-https-request-in-ios-9-with-self-signed-certificate">Making HTTPS request in iOS 9 with self-signed certificate</a></li>
<li><a href="https://stackoverflow.com/questions/34327857/ios9-self-signed-certificate-and-app-transport-security">ios9 self signed certificate and app transport security</a></li>
</ul>

<p>posted Alamofire git issue</p>

<ul>
<li><a href="https://github.com/Alamofire/Alamofire/issues/538" rel="noreferrer">'CFNetwork SSLHandshake failed (-9847)' error when performing a non-SSL request #538</a> </li>
<li><a href="https://github.com/Alamofire/Alamofire/issues/876" rel="noreferrer">Self-Signed Certificate not accepted #876</a> </li>
<li><a href="https://github.com/Alamofire/Alamofire/issues/977" rel="noreferrer">how can I connecting my server as HTTPS with using self-signed Certificate file #977</a> </li>
</ul>

<hr>

<p>My <strong>Info.pist</strong> file is updated for ATS settings this way</p>

<pre><code>&lt;key&gt;NSAppTransportSecurity&lt;/key&gt;
    &lt;dict&gt;
        &lt;key&gt;NSExceptionDomains&lt;/key&gt;
        &lt;dict&gt;
            &lt;key&gt;filename.hostname.net&lt;/key&gt;
            &lt;dict&gt;
                &lt;key&gt;NSExceptionRequiresForwardSecrecy&lt;/key&gt;
                &lt;false/&gt;
                &lt;key&gt;NSExceptionAllowsInsecureHTTPLoads&lt;/key&gt;
                &lt;true/&gt;
                &lt;key&gt;NSIncludesSubdomains&lt;/key&gt;
                &lt;true/&gt;
                &lt;key&gt;NSTemporaryExceptionAllowsInsecureHTTPLoads&lt;/key&gt;
                &lt;true/&gt;
            &lt;/dict&gt;
        &lt;/dict&gt;
    &lt;/dict&gt;
</code></pre>

<hr>

<p>Meanwhile I am able to get response for </p>

<p><strong>http</strong>://filename.hostname.net</p>

<p>and <strong>https</strong>://google.com</p>

<p><strong>but</strong> not for <strong>https</strong>://filename.hostname.net</p>

<p>Can anyone please suggest me why I am not able to get this working after huge efforts?</p>