0

I'm trying to use a SSL (from OPENSSL), but I don't know how to put it on the request, neither on URLSession.

I have already put the App Transport Security Settings and the Exception Domains on the Info.plist.

The requests without HTTPS goes great.

Someone can help me with this?

  • 1
    Can you explain in a little more detail what you are actually wanting to do – adamfowlerphoto Jun 05 '17 at 19:42
  • How does OpenSSL factor into things? Can you show some code? Why are you not using App Transport Security for both HTTPS and HTTP (instead of just HTTP)? – jww Jun 06 '17 at 02:05
  • I need to do a request with a self trust SSL, but I don't know how to configure this certificate to my connection. This is the error `NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813) Optional(Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “myDomain.com” which could put your confidential information at risk."` – Gabriel Ribeiro Silva Jun 06 '17 at 13:35

1 Answers1

3

You can’t use OpenSSL together with NSURLSession, it uses the built-in SSL library provided by the system and has no extension points where you could get a third-party SSL implementation in. There is no reason to do that.

If you want to use the built-in SSL functionality you just use an HTTPS URL and the system does everything for you. Of course your server also has to support HTTPS.

Sven
  • 22,475
  • 4
  • 52
  • 71
  • 1
    I'm think the question is one of the cases where the OpenSSL tag was added to the soup of tags. The OP meant HTTPS and SSL, and OpenSSL got caught up with them. An answer should probably focus on App Transport Security Setting, like [How do I load an HTTP URL with App Transport Security](https://stackoverflow.com/q/30731785/608639) (and possibly Apple's `SecureTransport`). – jww Jun 06 '17 at 01:59