Skip to content

Commit 7720dac

Browse files
author
Lealem Amedie
committed
Allow option to create SSL without key/cert in ctx
1 parent dcfa410 commit 7720dac

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/internal.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
* - WOLFSSL_HARDEN_TLS_NO_SCR_CHECK
9090
* - WOLFSSL_HARDEN_TLS_NO_PKEY_CHECK
9191
* - WOLFSSL_HARDEN_TLS_ALLOW_ALL_CIPHERSUITES
92+
* WOLFSSL_NO_INIT_CTX_KEY
93+
* Allows SSL objects to be created from a CTX without a loaded key/cert
94+
* pair
9295
*/
9396

9497

@@ -7060,9 +7063,13 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
70607063

70617064
/* Initialize SSL with the appropriate fields from it's ctx */
70627065
/* requires valid arrays and suites unless writeDup ing */
7063-
if ((ret = SetSSL_CTX(ssl, ctx, writeDup)) != WOLFSSL_SUCCESS)
7066+
if ((ret = SetSSL_CTX(ssl, ctx, writeDup)) != WOLFSSL_SUCCESS
7067+
#ifdef WOLFSSL_NO_INIT_CTX_KEY
7068+
&& ret != NO_PRIVATE_KEY
7069+
#endif
7070+
) {
70647071
return ret;
7065-
7072+
}
70667073
ssl->options.dtls = ssl->version.major == DTLS_MAJOR;
70677074

70687075
#ifdef HAVE_WRITE_DUP

tests/api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3785,7 +3785,7 @@ static int test_server_wolfSSL_new(void)
37853785
/* invalid context */
37863786
ExpectNull(ssl = wolfSSL_new(NULL));
37873787
#if !defined(WOLFSSL_SESSION_EXPORT) && !defined(WOLFSSL_QT) && \
3788-
!defined(OPENSSL_EXTRA)
3788+
!defined(OPENSSL_EXTRA) && !defined(WOLFSSL_NO_INIT_CTX_KEY)
37893789
ExpectNull(ssl = wolfSSL_new(ctx_nocert));
37903790
#endif
37913791

0 commit comments

Comments
 (0)