xCode 9 - iOS 11: NSURLConnection - sendAsynchronousRequest fails

前端 未结 3 1685
醉酒成梦
醉酒成梦 2021-01-04 00:41

I just downloaded the latest version of xCode (9.0 beta (9M136h)).

However, when I try to make a request to my server in iOS 11 simulator (Using NSURLConnection send

相关标签:
3条回答
  • 2021-01-04 01:23

    You need to allow your application to run HTTP (no S) connections. By default, Apple only allows HTTPS:

    1. go to your info.plist

      here

    2. then press the plus icon on any of them

    3. Search for "App Transport Security Settings" here

    4. click the little arrow to the left and find "Allow arbitrary loads", by default it is set to "NO" change it to "YES"

    0 讨论(0)
  • 2021-01-04 01:24

    Since you've got an invalid certificate error, I'll make the following suggestion based on my personal security practice.

    If you're still in your servicing terms with your CA, ask them to issue a new valid certificate for you.

    Check your Keychain setting and make sure no CA cert is missing.

    Alternatively, you can issue your own self-signed certificate for testing purposes, and add it to your local Keychain as trust anchor. A search for "how to create self-signed x509 certificate" will return something you might find useful.

    0 讨论(0)
  • 2021-01-04 01:31

    For all of you who get this error in iOS 11, please make sure you're working against valid (secured) certificate in your server.

    In our case, the certificate wasn't strict enough.

    Once our server guy integrated new valid certificate, the problem has gone.

    One way to check if the certificate is secured, is to past the problematic link in the browser.

    As a result, you might see that the connection is not secured:

    0 讨论(0)
提交回复
热议问题