There's some information in apple's documentation regarding this error:
errSSLXCertChainInvalid
— The peer has an invalid certificate chain; for example, signature verification within the chain failed, or no certificates were found.
And if you use SSLSetPeerDomainName
:
You can use this function to verify the common name field in the peer’s certificate. If you call this function and the common name in the certificate does not match the value you specify in the peerName parameter, then handshake fails and returns errSSLXCertChainInvalid.
I'd suggest uninstalling your device configuration profile, and creating a new one.
Also, it might be a good idea to check if you can access the server without errors from, say, a web browser. This will reveal if there is a problem with the certificate, or just your configuration profile on your iOS device.