Add cert callback retry test.
authorDr. Stephen Henson <steve@openssl.org>
Sun, 26 Jan 2014 00:51:09 +0000 (00:51 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Mon, 27 Jan 2014 14:41:38 +0000 (14:41 +0000)
(cherry picked from commit 3323314fc1c6d18e650a2de97f7cf9892ac92a60)

apps/s_cb.c
apps/s_server.c

index 22506a6805387e3086fefbd88bd1d6c1d345e6ad..78f1d93c6c9e2d9a05c582aa2a854c502284f1d1 100644 (file)
@@ -1264,6 +1264,16 @@ static int set_cert_cb(SSL *ssl, void *arg)
        {
        int i, rv;
        SSL_EXCERT *exc = arg;
+#ifdef CERT_CB_TEST_RETRY
+       static int retry_cnt;
+       if (retry_cnt < 5)
+               {
+               retry_cnt++;
+               fprintf(stderr, "Certificate callback retry test: count %d\n",
+                                                               retry_cnt);
+               return -1;
+               }
+#endif
        SSL_certs_clear(ssl);
 
        if (!exc)
index 8fbe9c5113a743f5d8faf33c79203dc3f2910272..6aa4161b6449baafea08f938c37eddef447d83e6 100644 (file)
@@ -2610,6 +2610,15 @@ static int init_ssl_connection(SSL *con)
 
 
        i=SSL_accept(con);
+#ifdef CERT_CB_TEST_RETRY
+       {
+       while (i <= 0 && SSL_get_error(con,i) == SSL_ERROR_WANT_X509_LOOKUP && SSL_state(con) == SSL3_ST_SR_CLNT_HELLO_C) 
+               {
+               fprintf(stderr, "LOOKUP from certificate callback during accept\n");
+               i=SSL_accept(con);
+               }
+       }
+#endif
 #ifndef OPENSSL_NO_SRP
        while (i <= 0 &&  SSL_get_error(con,i) == SSL_ERROR_WANT_X509_LOOKUP) 
                {