I am receiving an authentication challenge from a server my app is trying to connect to, so I have implemented the connection:didReceiveAuthenticationChallenge:
I finally found the answer. I was supposed to use SecIdentityCopyCertificate(identity, &certificateRef); instead of SecCertificateCreateWithData(nil, inPKCS12Data); to create my certificate.