]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - test/servername_test.c
Update copyright year
[thirdparty/openssl.git] / test / servername_test.c
index cf9cdd174a16c759e23703f468ed9d0df4ff5d9e..ddf0417bc642cb1ab651bf7647abc4fd370a0390 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2021 The OpenSSL Project Authors. All Rights Reserved.
  * Copyright 2017 BaishanCloud. All rights reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
@@ -22,7 +22,7 @@
 
 #include "testutil.h"
 #include "internal/nelem.h"
-#include "ssltestlib.h"
+#include "helpers/ssltestlib.h"
 
 #define CLIENT_VERSION_LEN      2
 
@@ -31,6 +31,13 @@ static const char *host = "dummy-host";
 static char *cert = NULL;
 static char *privkey = NULL;
 
+#if defined(OPENSSL_NO_TLS1_3) || \
+    (defined(OPENSSL_NO_EC) && defined(OPENSSL_NO_DH))
+static int maxversion = TLS1_2_VERSION;
+#else
+static int maxversion = 0;
+#endif
+
 static int get_sni_from_client_hello(BIO *bio, char **sni)
 {
     long len;
@@ -101,6 +108,10 @@ static int client_setup_sni_before_state(void)
     if (!TEST_ptr(ctx))
         goto end;
 
+    if (maxversion > 0
+            && !TEST_true(SSL_CTX_set_max_proto_version(ctx, maxversion)))
+        goto end;
+
     con = SSL_new(ctx);
     if (!TEST_ptr(con))
         goto end;
@@ -149,6 +160,10 @@ static int client_setup_sni_after_state(void)
     if (!TEST_ptr(ctx))
         goto end;
 
+    if (maxversion > 0
+            && !TEST_true(SSL_CTX_set_max_proto_version(ctx, maxversion)))
+        goto end;
+
     con = SSL_new(ctx);
     if (!TEST_ptr(con))
         goto end;