Demo of use of errors in applications.
[openssl.git] / ssl / ssl_cert.c
index d442e5418f3d85339364621cb00fd8de312be712..005d82d63025fcd01f0640e4d04f55f71abf507c 100644 (file)
@@ -599,6 +599,31 @@ int ssl_cert_add1_chain_cert(CERT *c, X509 *x)
        return 1;
        }
 
+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)
+                       {
+                       c->key = &c->pkeys[i];
+                       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;
+       }
+
 void ssl_cert_set_cert_cb(CERT *c, int (*cb)(SSL *ssl, void *arg), void *arg)
        {
        c->cert_cb = cb;