Skip to content

Commit 95675c7

Browse files
authored
Merge pull request #6455 from lealem47/INIT_SSL_NO_CTX_KEY
Allow option to create SSL without key/cert in ctx
2 parents 9fc68f4 + 7720dac commit 95675c7

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

@@ -7082,9 +7085,13 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
70827085

70837086
/* Initialize SSL with the appropriate fields from it's ctx */
70847087
/* requires valid arrays and suites unless writeDup ing */
7085-
if ((ret = SetSSL_CTX(ssl, ctx, writeDup)) != WOLFSSL_SUCCESS)
7088+
if ((ret = SetSSL_CTX(ssl, ctx, writeDup)) != WOLFSSL_SUCCESS
7089+
#ifdef WOLFSSL_NO_INIT_CTX_KEY
7090+
&& ret != NO_PRIVATE_KEY
7091+
#endif
7092+
) {
70867093
return ret;
7087-
7094+
}
70887095
ssl->options.dtls = ssl->version.major == DTLS_MAJOR;
70897096

70907097
#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)