Need ATS Help on Intranet Server

I created a self-signed certificate for a intranet only web service that the iOS app uses JSON to get data from. I cannot connect due to error:

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)


This is something intended to be used within an internal network only with an IP address or DNS name when configured. I created the cert and key using OpenSSL on Windows. Server is ASP.Net running on IIS 8 with the certificate installed. Server is being moved to SSL because of ATS and so far been a large effort met with only futility. Is it because I want to use a self-signed option? It makes no sense to pay a cert company $50+ to issue a certificate for a intranet server that they can't even access to verify. I ran TLSTool on my Mac to the server and the results are below.


TLSTool result:

* input stream did open

* output stream did open

* output stream has space

* protocol: TLS 1.2

* cipher: ECDHE_RSA_WITH_AES_256_CBC_SHA384

* trust result: proceed

* certificate info:

* 0 rsaEncryption 2048 sha256-with-rsa-signature 'xx.xx.xx.xx' (redacted by poster)

* error NSPOSIXErrorDomain / 54

* bytes sent 0, bytes received 0


I should add that I even loaded the Certificate under Profiles in the Settings on the iPhone simulator, but that did not help.

I ran TLSTool on my Mac to the server and the results are below.

It seems that your server hit met the most obvious ATS requirements:

  • TLS 1.2

  • a cypher suite that supports forward secrecy (

    ECDHE_RSA_WITH_AES_256_CBC_SHA384
    )
  • a left certificate with suitable key (

    rsaEncryption 2048
    )
  • a left certificate signed by a suitable hash algorithm (

    sha256-with-rsa-signature
    )

Is it because I want to use a self-signed option? It makes no sense to pay a cert company $50+ to issue a certificate for a intranet server that they can't even access to verify.

To be clear, I strongly recommend against using a self-signed certificate. I understand the reasons why you don’t want to get a certificate issued by a trusted CA, but that’s not your only alternative. If you’re working in an enterprise environment, your enterprise should run a CA (it probably already does so), install its root certificate on your client devices, and then use that CA to issue a certificate for your server.

If you’re running a really small enterprise, and one that doesn’t already have its own CA, it’s easy to run one using a Mac. Technote 2326 Creating Certificates for TLS Testing has the details. That’s what I do for my home (-:

Having said that, ATS is quite compatible with self-signed certificates. You have two general strategies:

  • Install the self-signed certificate on the device itself. If the certificate is set up correctly, the system will trust the certificate for your server and that gets you past that ATS check.

  • Disable the ATS ‘server certificate must to be trusted’ requirement using the

    NSExceptionAllowsInsecureHTTPLoads
    property key. Then allow the connection via NSURLSession’s authentication challenge mechanism.

WARNING If you do the latter you must do correct HTTPS server trust evaluation, lest you undo all the security benefits of switching to HTTPS. Technote 2232 HTTPS Server Trust Evaluation explains how to do this.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you for your informative reply!


What I am trying to do is use OpenSSL on Windows to generate my own CA and make certificates based off of that. I have made root PEM and KEY files and for IIS made PEM and KEY files that I used OpenSSL to combine to a PFX file. I put the PFX file in the IIS certificates and used the same PFX in the iOS Simulator. Settings in the simulator show a verified certificate with the right IP address under Profile so it looks like the certificate installed properly. I do also have the NSExceptionAllowsInsecureHTTPLoads key in my info.plist under NSAppTransportSecurity as a Boolean with the value set to YES.


I still get the error NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)


Is there anywhere to look up what that error code even means? I appreciate Apple is trying to improve security for iOS users, it is very important, but I am beyond frustrated with the lack of clarity.

… and used the same PFX in the iOS Simulator.

This makes no sense. A PFX file is the same as a

.p12
, that it, is holds a PKCS#12 blob. It’s typically used to pass around an digital identity (the combination of a certificate and the private key that matches the public key in that certificate), not a root certificate.

If you want the device to trust certificate’s issued by your CA’s root certificate, you should install that root certificate on your device. In OpenSSL terms, encode the root certificate as DER, then put it in a

.cer
file, then install that on the device.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Need ATS Help on Intranet Server
 
 
Q