Allow match selecting of current certificate.
authorDr. Stephen Henson <steve@openssl.org>
Wed, 13 Nov 2013 22:57:11 +0000 (22:57 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Wed, 13 Nov 2013 23:48:35 +0000 (23:48 +0000)
If pointer comparison for current certificate fails check
to see if a match using X509_cmp succeeds for the current
certificate: this is useful for cases where the certificate
pointer is not available.

ssl/ssl_cert.c

index 9d77ef79a2fea19ae2a5bf0ce3dcfeea0705c9c0..005d82d63025fcd01f0640e4d04f55f71abf507c 100644 (file)
@@ -602,6 +602,8 @@ int ssl_cert_add1_chain_cert(CERT *c, X509 *x)
 int ssl_cert_select_current(CERT *c, X509 *x)
        {
        int i;
+       if (x == NULL)
+               return 0;
        for (i = 0; i < SSL_PKEY_NUM; i++)
                {
                if (c->pkeys[i].x509 == x)
@@ -610,6 +612,15 @@ int ssl_cert_select_current(CERT *c, X509 *x)
                        return 1;
                        }
                }
+
+       for (i = 0; i < SSL_PKEY_NUM; i++)
+               {
+               if (c->pkeys[i].x509 && !X509_cmp(c->pkeys[i].x509, x))
+                       {
+                       c->key = &c->pkeys[i];
+                       return 1;
+                       }
+               }
        return 0;
        }