Hello,
I'm working on an app which requires two distinct connections back to a server (due to requirements of the server itself). I originally used NSURLConnection for both connections, but found that they were being bundled together into a single stream. To get around that, the second connection was changed to use NSOutputStream and NSInputStream with CFStreamCreatePairWithSocketToHost. This solution worked for our needs with iOS9.
With iOS10, however, the stream(s) created by CFStreamCreatePairWithSocketToHost fail to authenticate with self-signed SSL certificates, which the app needs to be able to work with. While the NSURLConnection's stream works fine, the other fails with "CFNetwork SSLHandshake failed (-9807)". It works fine for servers with "real" certificates, but we can't guarantee that all servers will have those.
"Allow Arbitrary Loads" is set to YES in info.plist; I believe that setting is what allows the NSURLConnection to work. CFStreamCreatePairWithSocketToHost seems to ignore it.
So there are two questions:
- Is it possible to configure 2 NSURLConnections to remain independent of each other, so that the server will receive them as different streams? This would allow me to remove CFStreamCreatePairWithSocketToHost entirely.
- If (1) is not possible, can the NSOutputStream from CFStreamCreatePairWithSocketToHost be configured to trust self-signed SSL certificates?