SSL Socket connection iOS

前端 未结 2 923
灰色年华
灰色年华 2021-02-01 11:05

I am trying to setup a secure connection to a java run SSLServerSocket.

I have created my own root CA, and have signed the certificate that the Java SSLServerSocket usin

相关标签:
2条回答
  • 2021-02-01 11:09

    Technote 2232, "HTTPS Server Trust Evaluation", should have all the answers you need. There is documentation and several examples of how to evaluate server trust.

    0 讨论(0)
  • 2021-02-01 11:09

    I had this same problem, and while adding the certificate manually does fix the issue, that also means having to update the app every time the certificate on the server changes (such as when it expires, which, in my case, was going to happen in a matter of days).

    If you're using an IP address to connect to the socket, and the certificate is for the FQDN (fully qualified domain name, i.e. subdomain.example.com), then when the operating system checks the certificate, it is going to look at the IP address you're connecting to, compare it to the name in the certificate, and think the two are different, causing the chain to fail validation.

    So for anyone else who runs into this problem, I recommend using the FQDN in the second parameter to CFStreamCreatePairWithSocketToHost rather than the IP address. After that, it should work without having to include the certificate in the bundle and manually validate.

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