12
I'm trying to implement mutual authentication in IOS 5 but i'm having troubles:
{NSUnderlyingError = "Error Domain=kCFErrorDomainCFNetwork Code=-1200 \"An SSL error has occurred and a secure connection to the server cannot be made.\" UserInfo=0x18d830 {NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., _kCFNetworkCFStreamSSLErrorOriginalValue=-9800, _kCFStreamPropertySSLClientCertificateState=0, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSErrorFailingURLStringKey=https://192.168.24.110:8081/t01.json, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0xceaa2d0>, NSErrorFailingURLKey=https://192.168.24.110:8081/t01.json}
I generated keys, certificates and pkcs12 for server (either self signed or with a fake CA I always got that problem) and client this way:
openssl genrsa -out client.key 1024
openssl req -new -key client.key -out client.csr
self-signed
openssl req -new -key ca.key -x509 -days 1095 -out ca.crt
CA signed
openssl x509 -req -days 365 -in client.csr -CA server.crt -CAkey server.key -CAcreateserial -out client.crt
CRT to PEM
openssl x509 -in client.crt -out client.der -outform DER
openssl x509 -in client.der -inform DER -out client.pem -outform PEM
PEM TO PKCS 12
openssl pkcs12 -export -in client.pem -inkey client.key -out client.p12
The resulting client.p12 file works perfectly when I import it in the browser (FF15). So the problem is not locate in the previous steps.
IOS side I tried this example: http://vanjakom.wordpress.com/tag/nsurlconnection/
and this is what I wrote when I found that example not working:
// Returns an array containing the certificate
- (CFArrayRef)getCertificate:(SecIdentityRef) identity {
SecCertificateRef certificate = nil;
SecIdentityCopy