X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/d8f41ccd20de16f8ebe2ccc84d47bf1cb2b26bbb..60c433a9f80a92b51b33f65f1f58883e8fe843be:/Security/libsecurity_ssl/lib/sslCrypto.c diff --git a/Security/libsecurity_ssl/lib/sslCrypto.c b/Security/libsecurity_ssl/lib/sslCrypto.c index 07457375..600916cc 100644 --- a/Security/libsecurity_ssl/lib/sslCrypto.c +++ b/Security/libsecurity_ssl/lib/sslCrypto.c @@ -187,13 +187,17 @@ static OSStatus sslVerifyCertChain( OSStatus status; SecTrustRef trust = NULL; - assert(certChain); - if (arePeerCerts) { /* renegotiate - start with a new SecTrustRef */ CFReleaseNull(ctx->peerSecTrust); } + if(certChain==NULL) { + sslErrorLog("***Error: NULL cert chain\n"); + status = errSSLXCertChainInvalid; + goto errOut; + } + status = sslCreateSecTrust(ctx, certChain, arePeerCerts, &trust); if (!ctx->enableCertVerify) { @@ -446,8 +450,14 @@ tls_verify_peer_cert(SSLContext *ctx) if(err) goto out; - /* Set the public key */ - tls_set_peer_pubkey(ctx->hdsk, certs); + /* Set the public key, only if we have certs. + We don't return an handshake error if there is no cert, + The fact that there is no cert should be reflected in the + trust results above, or will be handle when the application + does its own trust evaluation. */ + if(certs) { + require_noerr(err=tls_set_peer_pubkey(ctx->hdsk, certs), out); + } /* Now that cert verification is done, update context state */ /* (this code was formerly in SSLProcessHandshakeMessage, */