From: shangxiaoyang <15063566195@163.com>
Date: Thu, 9 Mar 2023 14:52:19 +0800
Subject: =?utf-8?b?5ZCM5q2l6auY54mI5pys6KGl5LiB5Y+K5omT5YyF5paH5Lu2?=

---
 doc/man3/SSL_CTX_set_security_level.pod |   9 +-
 ssl/ssl_cert.c                          |  14 +-
 test/bad_dtls_test.c                    |   2 +
 test/helpers/ssltestlib.c               |  10 +
 test/openssl.cnf                        | 353 ++++++++++++++++++++++++++++++++
 test/recipes/70-test_sslmessages.t      |   2 +-
 test/recipes/70-test_sslsigalgs.t       |  14 +-
 test/recipes/70-test_sslsignature.t     |   4 +-
 test/recipes/80-test_ssl_old.t          |  16 +-
 test/run_tests.pl                       |   2 +-
 test/ssl_test.c                         |  10 +
 util/perl/TLSProxy/Proxy.pm             |   8 +-
 12 files changed, 406 insertions(+), 38 deletions(-)
 create mode 100644 test/openssl.cnf

diff --git a/doc/man3/SSL_CTX_set_security_level.pod b/doc/man3/SSL_CTX_set_security_level.pod
index a4595490013b..a58552848855 100644
--- a/doc/man3/SSL_CTX_set_security_level.pod
+++ b/doc/man3/SSL_CTX_set_security_level.pod
@@ -86,22 +86,20 @@ bits.
 Security level set to 112 bits of security. As a result RSA, DSA and DH keys
 shorter than 2048 bits and ECC keys shorter than 224 bits are prohibited.
 In addition to the level 1 exclusions any cipher suite using RC4 is also
-prohibited. SSL version 3 is also not allowed. Compression is disabled.
+prohibited. On Ubuntu, TLS versions below 1.2 are not permitted. Compression is disabled.
 
 =item B<Level 3>
 
 Security level set to 128 bits of security. As a result RSA, DSA and DH keys
 shorter than 3072 bits and ECC keys shorter than 256 bits are prohibited.
 In addition to the level 2 exclusions cipher suites not offering forward
-secrecy are prohibited. TLS versions below 1.1 are not permitted. Session
-tickets are disabled.
+secrecy are prohibited. Session tickets are disabled.
 
 =item B<Level 4>
 
 Security level set to 192 bits of security. As a result RSA, DSA and
 DH keys shorter than 7680 bits and ECC keys shorter than 384 bits are
-prohibited.  Cipher suites using SHA1 for the MAC are prohibited. TLS
-versions below 1.2 are not permitted.
+prohibited.  Cipher suites using SHA1 for the MAC are prohibited.
 
 =item B<Level 5>
 
@@ -118,6 +116,7 @@ I<Documentation to be provided.>
 
 The default security level can be configured when OpenSSL is compiled by
 setting B<-DOPENSSL_TLS_SECURITY_LEVEL=level>. If not set then 1 is used.
+On Ubuntu, 2 is used.
 
 The security framework disables or reject parameters inconsistent with the
 set security level. In the past this was difficult as applications had to set
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
index e4168e74c276..5bf3aaba3b53 100644
--- a/ssl/ssl_cert.c
+++ b/ssl/ssl_cert.c
@@ -1050,18 +1050,12 @@ static int ssl_security_default_callback(const SSL *s, const SSL_CTX *ctx,
         }
     case SSL_SECOP_VERSION:
         if (!SSL_IS_DTLS(s)) {
-            /* SSLv3 not allowed at level 2 */
-            if (nid <= SSL3_VERSION && level >= 2)
-                return 0;
-            /* TLS v1.1 and above only for level 3 */
-            if (nid <= TLS1_VERSION && level >= 3)
-                return 0;
-            /* TLS v1.2 only for level 4 and above */
-            if (nid <= TLS1_1_VERSION && level >= 4)
+            /* TLS v1.2 only for level 2 and above */
+            if (nid <= TLS1_1_VERSION && level >= 2)
                 return 0;
         } else {
-            /* DTLS v1.2 only for level 4 and above */
-            if (DTLS_VERSION_LT(nid, DTLS1_2_VERSION) && level >= 4)
+            /* DTLS v1.2 only for level 2 and above */
+            if (DTLS_VERSION_LT(nid, DTLS1_2_VERSION) && level >= 2)
                 return 0;
         }
         break;
diff --git a/test/bad_dtls_test.c b/test/bad_dtls_test.c
index e6ee1ea09f6d..8a3cd726c8f6 100644
--- a/test/bad_dtls_test.c
+++ b/test/bad_dtls_test.c
@@ -491,6 +491,8 @@ static int test_bad_dtls(void)
         goto end;
 
     ctx = SSL_CTX_new(DTLS_client_method());
+    if (TEST_ptr(ctx))
+        SSL_CTX_set_security_level(ctx, 1);
     if (!TEST_ptr(ctx)
             || !TEST_true(SSL_CTX_set_min_proto_version(ctx, DTLS1_BAD_VER))
             || !TEST_true(SSL_CTX_set_max_proto_version(ctx, DTLS1_BAD_VER))
diff --git a/test/helpers/ssltestlib.c b/test/helpers/ssltestlib.c
index 4c17faea54a7..1a1dce00c3d8 100644
--- a/test/helpers/ssltestlib.c
+++ b/test/helpers/ssltestlib.c
@@ -754,6 +754,11 @@ int create_ssl_ctx_pair(OSSL_LIB_CTX *libctx, const SSL_METHOD *sm,
         max_proto_version = TLS1_2_VERSION;
 #endif
 
+    if (serverctx != NULL && SSL_CTX_get_security_level(serverctx) == 2)
+            SSL_CTX_set_security_level(serverctx, 1);
+    if (clientctx != NULL && SSL_CTX_get_security_level(clientctx) == 2)
+            SSL_CTX_set_security_level(clientctx, 1);
+
     if (serverctx != NULL
             && ((min_proto_version > 0
                  && !TEST_true(SSL_CTX_set_min_proto_version(serverctx,
@@ -922,6 +927,11 @@ int create_ssl_objects(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
     else if (!TEST_ptr(clientssl = SSL_new(clientctx)))
         goto error;
 
+    if (SSL_get_security_level(serverssl) == 2)
+            SSL_set_security_level(serverssl, 1);
+    if (SSL_get_security_level(clientssl) == 2)
+            SSL_set_security_level(clientssl, 1);
+
     if (SSL_is_dtls(clientssl)) {
         if (!TEST_ptr(s_to_c_bio = BIO_new(bio_s_mempacket_test()))
                 || !TEST_ptr(c_to_s_bio = BIO_new(bio_s_mempacket_test())))
diff --git a/test/openssl.cnf b/test/openssl.cnf
new file mode 100644
index 000000000000..4fd5286d2e25
--- /dev/null
+++ b/test/openssl.cnf
@@ -0,0 +1,353 @@
+#
+# OpenSSL example configuration file.
+# This is mostly being used for generation of certificate requests.
+#
+
+# Note that you can include other files from the main configuration
+# file using the .include directive.
+#.include filename
+
+# This definition stops the following lines choking if HOME isn't
+# defined.
+HOME			= .
+
+# Extra OBJECT IDENTIFIER info:
+#oid_file		= $ENV::HOME/.oid
+oid_section		= new_oids
+
+# To use this configuration file with the "-extfile" option of the
+# "openssl x509" utility, name here the section containing the
+# X.509v3 extensions to use:
+# extensions		=
+# (Alternatively, use a configuration file that has only
+# X.509v3 extensions in its main [= default] section.)
+
+[ new_oids ]
+
+# We can add new OIDs in here for use by 'ca', 'req' and 'ts'.
+# Add a simple OID like this:
+# testoid1=1.2.3.4
+# Or use config file substitution like this:
+# testoid2=${testoid1}.5.6
+
+# Policies used by the TSA examples.
+tsa_policy1 = 1.2.3.4.1
+tsa_policy2 = 1.2.3.4.5.6
+tsa_policy3 = 1.2.3.4.5.7
+
+####################################################################
+[ ca ]
+default_ca	= CA_default		# The default ca section
+
+####################################################################
+[ CA_default ]
+
+dir		= ./demoCA		# Where everything is kept
+certs		= $dir/certs		# Where the issued certs are kept
+crl_dir		= $dir/crl		# Where the issued crl are kept
+database	= $dir/index.txt	# database index file.
+#unique_subject	= no			# Set to 'no' to allow creation of
+					# several certs with same subject.
+new_certs_dir	= $dir/newcerts		# default place for new certs.
+
+certificate	= $dir/cacert.pem 	# The CA certificate
+serial		= $dir/serial 		# The current serial number
+crlnumber	= $dir/crlnumber	# the current crl number
+					# must be commented out to leave a V1 CRL
+crl		= $dir/crl.pem 		# The current CRL
+private_key	= $dir/private/cakey.pem# The private key
+
+x509_extensions	= usr_cert		# The extensions to add to the cert
+
+# Comment out the following two lines for the "traditional"
+# (and highly broken) format.
+name_opt 	= ca_default		# Subject Name options
+cert_opt 	= ca_default		# Certificate field options
+
+# Extension copying option: use with caution.
+# copy_extensions = copy
+
+# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
+# so this is commented out by default to leave a V1 CRL.
+# crlnumber must also be commented out to leave a V1 CRL.
+# crl_extensions	= crl_ext
+
+default_days	= 365			# how long to certify for
+default_crl_days= 30			# how long before next CRL
+default_md	= default		# use public key default MD
+preserve	= no			# keep passed DN ordering
+
+# A few difference way of specifying how similar the request should look
+# For type CA, the listed attributes must be the same, and the optional
+# and supplied fields are just that :-)
+policy		= policy_match
+
+# For the CA policy
+[ policy_match ]
+countryName		= match
+stateOrProvinceName	= match
+organizationName	= match
+organizationalUnitName	= optional
+commonName		= supplied
+emailAddress		= optional
+
+# For the 'anything' policy
+# At this point in time, you must list all acceptable 'object'
+# types.
+[ policy_anything ]
+countryName		= optional
+stateOrProvinceName	= optional
+localityName		= optional
+organizationName	= optional
+organizationalUnitName	= optional
+commonName		= supplied
+emailAddress		= optional
+
+####################################################################
+[ req ]
+default_bits		= 2048
+default_keyfile 	= privkey.pem
+distinguished_name	= req_distinguished_name
+attributes		= req_attributes
+x509_extensions	= v3_ca	# The extensions to add to the self signed cert
+
+# Passwords for private keys if not present they will be prompted for
+# input_password = secret
+# output_password = secret
+
+# This sets a mask for permitted string types. There are several options.
+# default: PrintableString, T61String, BMPString.
+# pkix	 : PrintableString, BMPString (PKIX recommendation before 2004)
+# utf8only: only UTF8Strings (PKIX recommendation after 2004).
+# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
+# MASK:XXXX a literal mask value.
+# WARNING: ancient versions of Netscape crash on BMPStrings or UTF8Strings.
+string_mask = utf8only
+
+# req_extensions = v3_req # The extensions to add to a certificate request
+
+[ req_distinguished_name ]
+countryName			= Country Name (2 letter code)
+countryName_default		= AU
+countryName_min			= 2
+countryName_max			= 2
+
+stateOrProvinceName		= State or Province Name (full name)
+stateOrProvinceName_default	= Some-State
+
+localityName			= Locality Name (eg, city)
+
+0.organizationName		= Organization Name (eg, company)
+0.organizationName_default	= Internet Widgits Pty Ltd
+
+# we can do this but it is not needed normally :-)
+#1.organizationName		= Second Organization Name (eg, company)
+#1.organizationName_default	= World Wide Web Pty Ltd
+
+organizationalUnitName		= Organizational Unit Name (eg, section)
+#organizationalUnitName_default	=
+
+commonName			= Common Name (e.g. server FQDN or YOUR name)
+commonName_max			= 64
+
+emailAddress			= Email Address
+emailAddress_max		= 64
+
+# SET-ex3			= SET extension number 3
+
+[ req_attributes ]
+challengePassword		= A challenge password
+challengePassword_min		= 4
+challengePassword_max		= 20
+
+unstructuredName		= An optional company name
+
+[ usr_cert ]
+
+# These extensions are added when 'ca' signs a request.
+
+# This goes against PKIX guidelines but some CAs do it and some software
+# requires this to avoid interpreting an end user certificate as a CA.
+
+basicConstraints=CA:FALSE
+
+# This is typical in keyUsage for a client certificate.
+# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
+
+# PKIX recommendations harmless if included in all certificates.
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid,issuer
+
+# This stuff is for subjectAltName and issuerAltname.
+# Import the email address.
+# subjectAltName=email:copy
+# An alternative to produce certificates that aren't
+# deprecated according to PKIX.
+# subjectAltName=email:move
+
+# Copy subject details
+# issuerAltName=issuer:copy
+
+# This is required for TSA certificates.
+# extendedKeyUsage = critical,timeStamping
+
+[ v3_req ]
+
+# Extensions to add to a certificate request
+
+basicConstraints = CA:FALSE
+keyUsage = nonRepudiation, digitalSignature, keyEncipherment
+
+[ v3_ca ]
+
+
+# Extensions for a typical CA
+
+
+# PKIX recommendation.
+
+subjectKeyIdentifier=hash
+
+authorityKeyIdentifier=keyid:always,issuer
+
+basicConstraints = critical,CA:true
+
+# Key usage: this is typical for a CA certificate. However since it will
+# prevent it being used as an test self-signed certificate it is best
+# left out by default.
+# keyUsage = cRLSign, keyCertSign
+
+# Include email address in subject alt name: another PKIX recommendation
+# subjectAltName=email:copy
+# Copy issuer details
+# issuerAltName=issuer:copy
+
+# DER hex encoding of an extension: beware experts only!
+# obj=DER:02:03
+# Where 'obj' is a standard or added object
+# You can even override a supported extension:
+# basicConstraints= critical, DER:30:03:01:01:FF
+
+[ crl_ext ]
+
+# CRL extensions.
+# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.
+
+# issuerAltName=issuer:copy
+authorityKeyIdentifier=keyid:always
+
+[ proxy_cert_ext ]
+# These extensions should be added when creating a proxy certificate
+
+# This goes against PKIX guidelines but some CAs do it and some software
+# requires this to avoid interpreting an end user certificate as a CA.
+
+basicConstraints=CA:FALSE
+
+# This is typical in keyUsage for a client certificate.
+# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
+
+# PKIX recommendations harmless if included in all certificates.
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid,issuer
+
+# This stuff is for subjectAltName and issuerAltname.
+# Import the email address.
+# subjectAltName=email:copy
+# An alternative to produce certificates that aren't
+# deprecated according to PKIX.
+# subjectAltName=email:move
+
+# Copy subject details
+# issuerAltName=issuer:copy
+
+# This really needs to be in place for it to be a proxy certificate.
+proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo
+
+####################################################################
+[ tsa ]
+
+default_tsa = tsa_config1	# the default TSA section
+
+[ tsa_config1 ]
+
+# These are used by the TSA reply generation only.
+dir		= ./demoCA		# TSA root directory
+serial		= $dir/tsaserial	# The current serial number (mandatory)
+crypto_device	= builtin		# OpenSSL engine to use for signing
+signer_cert	= $dir/tsacert.pem 	# The TSA signing certificate
+					# (optional)
+certs		= $dir/cacert.pem	# Certificate chain to include in reply
+					# (optional)
+signer_key	= $dir/private/tsakey.pem # The TSA private key (optional)
+signer_digest  = sha256			# Signing digest to use. (Optional)
+default_policy	= tsa_policy1		# Policy if request did not specify it
+					# (optional)
+other_policies	= tsa_policy2, tsa_policy3	# acceptable policies (optional)
+digests     = sha1, sha256, sha384, sha512  # Acceptable message digests (mandatory)
+accuracy	= secs:1, millisecs:500, microsecs:100	# (optional)
+clock_precision_digits  = 0	# number of digits after dot. (optional)
+ordering		= yes	# Is ordering defined for timestamps?
+				# (optional, default: no)
+tsa_name		= yes	# Must the TSA name be included in the reply?
+				# (optional, default: no)
+ess_cert_id_chain	= no	# Must the ESS cert id chain be included?
+				# (optional, default: no)
+ess_cert_id_alg		= sha1	# algorithm to compute certificate
+				# identifier (optional, default: sha1)
+
+[insta] # CMP using Insta Demo CA
+# Message transfer
+server = pki.certificate.fi:8700
+# proxy = # set this as far as needed, e.g., http://192.168.1.1:8080
+# tls_use = 0
+path = pkix/
+
+# Server authentication
+recipient = "/C=FI/O=Insta Demo/CN=Insta Demo CA" # or set srvcert or issuer
+ignore_keyusage = 1 # potentially needed quirk
+unprotected_errors = 1 # potentially needed quirk
+extracertsout = insta.extracerts.pem
+
+# Client authentication
+ref = 3078 # user identification
+secret = pass:insta # can be used for both client and server side
+
+# Generic message options
+cmd = ir # default operation, can be overridden on cmd line with, e.g., kur
+
+# Certificate enrollment
+subject = "/CN=openssl-cmp-test"
+newkey = insta.priv.pem
+out_trusted = insta.ca.crt
+certout = insta.cert.pem
+
+[pbm] # Password-based protection for Insta CA
+# Server and client authentication
+ref = $insta::ref # 3078
+secret = $insta::secret # pass:insta
+
+[signature] # Signature-based protection for Insta CA
+# Server authentication
+trusted = insta.ca.crt # does not include keyUsage digitalSignature
+
+# Client authentication
+secret = # disable PBM
+key = $insta::newkey # insta.priv.pem
+cert = $insta::certout # insta.cert.pem
+
+[ir]
+cmd = ir
+
+[cr]
+cmd = cr
+
+[kur]
+# Certificate update
+cmd = kur
+oldcert = $insta::certout # insta.cert.pem
+
+[rr]
+# Certificate revocation
+cmd = rr
+oldcert = $insta::certout # insta.cert.pem
diff --git a/test/recipes/70-test_sslmessages.t b/test/recipes/70-test_sslmessages.t
index abb0f5aff905..e252fc81c7d7 100644
--- a/test/recipes/70-test_sslmessages.t
+++ b/test/recipes/70-test_sslmessages.t
@@ -421,7 +421,7 @@ SKIP: {
     $proxy->clear();
     $proxy->clientflags("-no_tls1_3");
     $proxy->serverflags("-no_tls1_3");
-    $proxy->ciphers("ECDHE-RSA-AES128-SHA");
+    $proxy->ciphers("ECDHE-RSA-AES128-SHA:\@SECLEVEL=1");
     $proxy->start();
     checkhandshake($proxy, checkhandshake::EC_HANDSHAKE,
                    checkhandshake::DEFAULT_EXTENSIONS
diff --git a/test/recipes/70-test_sslsigalgs.t b/test/recipes/70-test_sslsigalgs.t
index 48b9e43c3b39..ae4e5e89f004 100644
--- a/test/recipes/70-test_sslsigalgs.t
+++ b/test/recipes/70-test_sslsigalgs.t
@@ -129,7 +129,7 @@ SKIP: {
     #        should succeed
     $proxy->clear();
     $proxy->serverflags("-no_tls1_3");
-    $proxy->ciphers("ECDHE-RSA-AES128-SHA");
+    $proxy->ciphers("ECDHE-RSA-AES128-SHA:\@SECLEVEL=1");
     $proxy->filter(undef);
     $proxy->start();
     ok(TLSProxy::Message->success, "TLSv1.3 client TLSv1.2 server");
@@ -173,7 +173,7 @@ SKIP: {
     $proxy->clear();
     $testtype = EMPTY_SIG_ALGS_EXT;
     $proxy->clientflags("-no_tls1_3");
-    $proxy->ciphers("ECDHE-RSA-AES128-SHA");
+    $proxy->ciphers("ECDHE-RSA-AES128-SHA:\@SECLEVEL=1");
     $proxy->start();
     ok(TLSProxy::Message->fail, "Empty TLSv1.2 sigalgs");
 
@@ -181,7 +181,7 @@ SKIP: {
     $proxy->clear();
     $testtype = NO_KNOWN_SIG_ALGS;
     $proxy->clientflags("-no_tls1_3");
-    $proxy->ciphers("ECDHE-RSA-AES128-SHA");
+    $proxy->ciphers("ECDHE-RSA-AES128-SHA:\@SECLEVEL=1");
     $proxy->start();
     ok(TLSProxy::Message->fail, "No known TLSv1.3 sigalgs");
 
@@ -190,7 +190,7 @@ SKIP: {
     $proxy->clear();
     $testtype = NO_PSS_SIG_ALGS;
     $proxy->clientflags("-no_tls1_3");
-    $proxy->ciphers("ECDHE-RSA-AES128-SHA");
+    $proxy->ciphers("ECDHE-RSA-AES128-SHA:\@SECLEVEL=1");
     $proxy->start();
     ok(TLSProxy::Message->success, "No PSS TLSv1.2 sigalgs");
 
@@ -198,7 +198,7 @@ SKIP: {
     $proxy->clear();
     $testtype = PSS_ONLY_SIG_ALGS;
     $proxy->serverflags("-no_tls1_3");
-    $proxy->ciphers("ECDHE-RSA-AES128-SHA");
+    $proxy->ciphers("ECDHE-RSA-AES128-SHA:\@SECLEVEL=1");
     $proxy->start();
     ok(TLSProxy::Message->success, "PSS only sigalgs in TLSv1.2");
 
@@ -209,7 +209,7 @@ SKIP: {
     $proxy->clear();
     $testtype = PSS_ONLY_SIG_ALGS;
     $proxy->clientflags("-no_tls1_3 -sigalgs RSA+SHA256");
-    $proxy->ciphers("ECDHE-RSA-AES128-SHA");
+    $proxy->ciphers("ECDHE-RSA-AES128-SHA:\@SECLEVEL=1");
     $proxy->start();
     ok(TLSProxy::Message->fail, "Sigalg we did not send in TLSv1.2");
 
@@ -217,7 +217,7 @@ SKIP: {
     #         matches the certificate should fail in TLSv1.2
     $proxy->clear();
     $proxy->clientflags("-no_tls1_3 -sigalgs ECDSA+SHA256");
-    $proxy->ciphers("ECDHE-RSA-AES128-SHA");
+    $proxy->ciphers("ECDHE-RSA-AES128-SHA:\@SECLEVEL=1");
     $proxy->filter(undef);
     $proxy->start();
     ok(TLSProxy::Message->fail, "No matching TLSv1.2 sigalgs");
diff --git a/test/recipes/70-test_sslsignature.t b/test/recipes/70-test_sslsignature.t
index a9a77d5b8f1c..48b8357c2f59 100644
--- a/test/recipes/70-test_sslsignature.t
+++ b/test/recipes/70-test_sslsignature.t
@@ -103,8 +103,8 @@ SKIP: {
         $proxy->clear();
         $testtype = CORRUPT_TLS1_2_SERVER_KEY_EXCHANGE;
         $proxy->clientflags("-no_tls1_3");
-        $proxy->cipherc('DHE-RSA-AES128-SHA');
-        $proxy->ciphers('DHE-RSA-AES128-SHA');
+        $proxy->cipherc('DHE-RSA-AES128-SHA:\@SECLEVEL=1');
+        $proxy->ciphers('DHE-RSA-AES128-SHA:\@SECLEVEL=1');
         $proxy->start();
         ok(TLSProxy::Message->fail, "Corrupt <=TLSv1.2 ServerKeyExchange");
     }
diff --git a/test/recipes/80-test_ssl_old.t b/test/recipes/80-test_ssl_old.t
index 8c52b637fc82..d74ccd6f8712 100644
--- a/test/recipes/80-test_ssl_old.t
+++ b/test/recipes/80-test_ssl_old.t
@@ -583,32 +583,32 @@ sub testssl {
                 if $no_tls1_1;
 
         SKIP: {
-            skip "skipping auto DHE PSK test at SECLEVEL 3", 1
-                if ($no_dh || $no_psk);
+            skip "skipping auto DHE PSK test at SECLEVEL 3", 1;
+                # if ($no_dh || $no_psk);
 
             ok(run(test(['ssl_old_test', '-tls1_1', '-dhe4096', '-psk', '0102030405', '-cipher', '@SECLEVEL=3:DHE-PSK-AES256-CBC-SHA384'])),
                'test auto DHE PSK meets security strength');
           }
 
         SKIP: {
-            skip "skipping auto ECDHE PSK test at SECLEVEL 3", 1
-                if ($no_ec || $no_psk);
+            skip "skipping auto ECDHE PSK test at SECLEVEL 3", 1;
+                # if ($no_ec || $no_psk);
 
             ok(run(test(['ssl_old_test', '-tls1_1', '-no_dhe', '-psk', '0102030405', '-cipher', '@SECLEVEL=3:ECDHE-PSK-AES256-CBC-SHA384'])),
                'test auto ECDHE PSK meets security strength');
           }
 
         SKIP: {
-            skip "skipping no RSA PSK at SECLEVEL 3 test", 1
-                if ($no_rsa || $no_psk);
+            skip "skipping no RSA PSK at SECLEVEL 3 test", 1;
+                # if ($no_rsa || $no_psk);
 
             ok(!run(test(['ssl_old_test', '-tls1_1', '-no_dhe', '-psk', '0102030405', '-cipher', '@SECLEVEL=3:RSA-PSK-AES256-CBC-SHA384'])),
                'test auto RSA PSK does not meet security level 3 requirements (PFS)');
           }
 
         SKIP: {
-            skip "skipping no PSK at SECLEVEL 3 test", 1
-                if ($no_psk);
+            skip "skipping no PSK at SECLEVEL 3 test", 1;
+                # if ($no_psk);
 
             ok(!run(test(['ssl_old_test', '-tls1_1', '-no_dhe', '-psk', '0102030405', '-cipher', '@SECLEVEL=3:PSK-AES256-CBC-SHA384'])),
                'test auto PSK does not meet security level 3 requirements (PFS)');
diff --git a/test/run_tests.pl b/test/run_tests.pl
index 4384ebe28e0d..f82284e224b8 100644
--- a/test/run_tests.pl
+++ b/test/run_tests.pl
@@ -33,7 +33,7 @@ my $recipesdir = catdir($srctop, "test", "recipes");
 my $libdir = rel2abs(catdir($srctop, "util", "perl"));
 my $jobs = $ENV{HARNESS_JOBS} // 1;
 
-$ENV{OPENSSL_CONF} = rel2abs(catfile($srctop, "apps", "openssl.cnf"));
+$ENV{OPENSSL_CONF} = rel2abs(catfile($srctop, "test", "openssl.cnf"));
 $ENV{OPENSSL_CONF_INCLUDE} = rel2abs(catdir($bldtop, "test"));
 $ENV{OPENSSL_MODULES} = rel2abs(catdir($bldtop, "providers"));
 $ENV{OPENSSL_ENGINES} = rel2abs(catdir($bldtop, "engines"));
diff --git a/test/ssl_test.c b/test/ssl_test.c
index 4c2553ce27c1..eb37452e8fcd 100644
--- a/test/ssl_test.c
+++ b/test/ssl_test.c
@@ -409,6 +409,7 @@ static int test_handshake(int idx)
 #ifndef OPENSSL_NO_DTLS
     if (test_ctx->method == SSL_TEST_METHOD_DTLS) {
         server_ctx = SSL_CTX_new_ex(libctx, NULL, DTLS_server_method());
+        SSL_CTX_set_security_level(server_ctx, 1);
         if (!TEST_true(SSL_CTX_set_options(server_ctx,
                         SSL_OP_ALLOW_CLIENT_RENEGOTIATION))
                 || !TEST_true(SSL_CTX_set_max_proto_version(server_ctx, 0)))
@@ -420,19 +421,23 @@ static int test_handshake(int idx)
                     || !TEST_true(SSL_CTX_set_options(server2_ctx,
                             SSL_OP_ALLOW_CLIENT_RENEGOTIATION)))
                 goto err;
+            SSL_CTX_set_security_level(server2_ctx, 1);
         }
         client_ctx = SSL_CTX_new_ex(libctx, NULL, DTLS_client_method());
+        SSL_CTX_set_security_level(client_ctx, 1);
         if (!TEST_true(SSL_CTX_set_max_proto_version(client_ctx, 0)))
             goto err;
         if (test_ctx->handshake_mode == SSL_TEST_HANDSHAKE_RESUME) {
             resume_server_ctx = SSL_CTX_new_ex(libctx, NULL,
                                                DTLS_server_method());
+            SSL_CTX_set_security_level(resume_server_ctx, 1);
             if (!TEST_true(SSL_CTX_set_max_proto_version(resume_server_ctx, 0))
                     || !TEST_true(SSL_CTX_set_options(resume_server_ctx,
                             SSL_OP_ALLOW_CLIENT_RENEGOTIATION)))
                 goto err;
             resume_client_ctx = SSL_CTX_new_ex(libctx, NULL,
                                                DTLS_client_method());
+            SSL_CTX_set_security_level(resume_client_ctx, 1);
             if (!TEST_true(SSL_CTX_set_max_proto_version(resume_client_ctx, 0)))
                 goto err;
             if (!TEST_ptr(resume_server_ctx)
@@ -452,6 +457,7 @@ static int test_handshake(int idx)
 #endif
 
         server_ctx = SSL_CTX_new_ex(libctx, NULL, TLS_server_method());
+        SSL_CTX_set_security_level(server_ctx, 1);
         if (!TEST_true(SSL_CTX_set_max_proto_version(server_ctx, maxversion))
                 || !TEST_true(SSL_CTX_set_options(server_ctx,
                             SSL_OP_ALLOW_CLIENT_RENEGOTIATION)))
@@ -464,17 +470,20 @@ static int test_handshake(int idx)
                     || !TEST_true(SSL_CTX_set_options(server2_ctx,
                             SSL_OP_ALLOW_CLIENT_RENEGOTIATION)))
                 goto err;
+            SSL_CTX_set_security_level(server2_ctx, 1);
             if (!TEST_true(SSL_CTX_set_max_proto_version(server2_ctx,
                                                          maxversion)))
                 goto err;
         }
         client_ctx = SSL_CTX_new_ex(libctx, NULL, TLS_client_method());
+        SSL_CTX_set_security_level(client_ctx, 1);
         if (!TEST_true(SSL_CTX_set_max_proto_version(client_ctx, maxversion)))
             goto err;
 
         if (test_ctx->handshake_mode == SSL_TEST_HANDSHAKE_RESUME) {
             resume_server_ctx = SSL_CTX_new_ex(libctx, NULL,
                                                TLS_server_method());
+            SSL_CTX_set_security_level(resume_server_ctx, 1);
             if (!TEST_true(SSL_CTX_set_max_proto_version(resume_server_ctx,
                                                          maxversion))
                     || !TEST_true(SSL_CTX_set_options(resume_server_ctx,
@@ -482,6 +491,7 @@ static int test_handshake(int idx)
                 goto err;
             resume_client_ctx = SSL_CTX_new_ex(libctx, NULL,
                                                TLS_client_method());
+            SSL_CTX_set_security_level(resume_client_ctx, 1);
             if (!TEST_true(SSL_CTX_set_max_proto_version(resume_client_ctx,
                                                          maxversion)))
                 goto err;
diff --git a/util/perl/TLSProxy/Proxy.pm b/util/perl/TLSProxy/Proxy.pm
index 3de10eccb94e..d3defae64eb0 100644
--- a/util/perl/TLSProxy/Proxy.pm
+++ b/util/perl/TLSProxy/Proxy.pm
@@ -97,9 +97,9 @@ sub new
         execute => $execute,
         cert => $cert,
         debug => $debug,
-        cipherc => "",
+        cipherc => "DEFAULT:\@SECLEVEL=1",
         ciphersuitesc => "",
-        ciphers => "AES128-SHA",
+        ciphers => "AES128-SHA:\@SECLEVEL=1",
         ciphersuitess => "TLS_AES_128_GCM_SHA256",
         flight => -1,
         direction => -1,
@@ -145,7 +145,7 @@ sub clearClient
 {
     my $self = shift;
 
-    $self->{cipherc} = "";
+    $self->{cipherc} = "DEFAULT:\@SECLEVEL=1";
     $self->{ciphersuitec} = "";
     $self->{flight} = -1;
     $self->{direction} = -1;
@@ -167,7 +167,7 @@ sub clear
     my $self = shift;
 
     $self->clearClient;
-    $self->{ciphers} = "AES128-SHA";
+    $self->{ciphers} = "AES128-SHA:\@SECLEVEL=1";
     $self->{ciphersuitess} = "TLS_AES_128_GCM_SHA256";
     $self->{serverflags} = "";
     $self->{serverconnects} = 1;
