summaryrefslogtreecommitdiffstats
path: root/test/helpers
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2021-01-14 15:50:20 +0000
committerMatt Caswell <matt@openssl.org>2021-02-05 15:22:40 +0000
commita763ca11777ce01a286751f3f3dd9b106ef74f30 (patch)
tree7ad54dd22661b8373f57ffefdee897b6282dc225 /test/helpers
parent8b1db5d329740bd5363fd1763d4030d0e015b521 (diff)
Stop disabling TLSv1.3 if ec and dh are disabled
Even if EC and DH are disabled then we may still be able to use TLSv1.3 if we have groups that have been plugged in by an external provider. Fixes #13767 Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13916)
Diffstat (limited to 'test/helpers')
-rw-r--r--test/helpers/ssltestlib.c49
1 files changed, 32 insertions, 17 deletions
diff --git a/test/helpers/ssltestlib.c b/test/helpers/ssltestlib.c
index 2366c3db4d..e339d7972c 100644
--- a/test/helpers/ssltestlib.c
+++ b/test/helpers/ssltestlib.c
@@ -685,18 +685,19 @@ static int always_retry_puts(BIO *bio, const char *str)
}
int create_ssl_ctx_pair(OSSL_LIB_CTX *libctx, const SSL_METHOD *sm,
-const SSL_METHOD *cm,
- int min_proto_version, int max_proto_version,
- SSL_CTX **sctx, SSL_CTX **cctx, char *certfile,
- char *privkeyfile)
+ const SSL_METHOD *cm, int min_proto_version,
+ int max_proto_version, SSL_CTX **sctx, SSL_CTX **cctx,
+ char *certfile, char *privkeyfile)
{
SSL_CTX *serverctx = NULL;
SSL_CTX *clientctx = NULL;
- if (*sctx != NULL)
- serverctx = *sctx;
- else if (!TEST_ptr(serverctx = SSL_CTX_new_ex(libctx, NULL, sm)))
- goto err;
+ if (sctx != NULL) {
+ if (*sctx != NULL)
+ serverctx = *sctx;
+ else if (!TEST_ptr(serverctx = SSL_CTX_new_ex(libctx, NULL, sm)))
+ goto err;
+ }
if (cctx != NULL) {
if (*cctx != NULL)
@@ -705,12 +706,25 @@ const SSL_METHOD *cm,
goto err;
}
- if ((min_proto_version > 0
- && !TEST_true(SSL_CTX_set_min_proto_version(serverctx,
- min_proto_version)))
- || (max_proto_version > 0
- && !TEST_true(SSL_CTX_set_max_proto_version(serverctx,
- max_proto_version))))
+#if !defined(OPENSSL_NO_TLS1_3) \
+ && defined(OPENSSL_NO_EC) \
+ && defined(OPENSSL_NO_DH)
+ /*
+ * There are no usable built-in TLSv1.3 groups if ec and dh are both
+ * disabled
+ */
+ if (max_proto_version == 0
+ && (sm == TLS_server_method() || cm == TLS_client_method()))
+ max_proto_version = TLS1_2_VERSION;
+#endif
+
+ if (serverctx != NULL
+ && ((min_proto_version > 0
+ && !TEST_true(SSL_CTX_set_min_proto_version(serverctx,
+ min_proto_version)))
+ || (max_proto_version > 0
+ && !TEST_true(SSL_CTX_set_max_proto_version(serverctx,
+ max_proto_version)))))
goto err;
if (clientctx != NULL
&& ((min_proto_version > 0
@@ -721,7 +735,7 @@ const SSL_METHOD *cm,
max_proto_version)))))
goto err;
- if (certfile != NULL && privkeyfile != NULL) {
+ if (serverctx != NULL && certfile != NULL && privkeyfile != NULL) {
if (!TEST_int_eq(SSL_CTX_use_certificate_file(serverctx, certfile,
SSL_FILETYPE_PEM), 1)
|| !TEST_int_eq(SSL_CTX_use_PrivateKey_file(serverctx,
@@ -731,13 +745,14 @@ const SSL_METHOD *cm,
goto err;
}
- *sctx = serverctx;
+ if (sctx != NULL)
+ *sctx = serverctx;
if (cctx != NULL)
*cctx = clientctx;
return 1;
err:
- if (*sctx == NULL)
+ if (sctx != NULL && *sctx == NULL)
SSL_CTX_free(serverctx);
if (cctx != NULL && *cctx == NULL)
SSL_CTX_free(clientctx);