Things to note before reading:
During the times the call to SSLHandshake fails it exchanges the following bytes:
5, 89, 5, 2797
It seems like it gives up once it starts reading certificates back from the server. I am assuming thats what the 2797 chunk of bytes is. SSLHandshake then fails and returns with error code -50.
During the times the SSLHandshake call succeeds it exchanges the following bytes:
5, 89, 5, 5574, 5, 333, 5, 4
75, 6, 45
5, 1, 5, 40
Then the handshake succeeds and returns noErr. I cannot for the life of me figure out why it fails when it does and succeeds when it does. Any input would be greatly appreciated.
Error -50 is
errSecParam, which is a very generic error indicating that someone (usually the caller, but potentially the remote peer) passed in bad parameters. There are lots of potential reasons for this failure and it’s hard to work out what went wrong based on the info you’ve posted.
Try poking at your server with TLSTool. If that works all the time there’s definitely someone wrong with your use of Secure Transport. OTOH, if that replicates the failure then it’s more likely to be a problem with the actual TLS traffic on the wire.
Also, double check that your I/O functions are working as expected; this post has the details.
Share and Enjoy
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"