Skip to content

Commit 498c740

Browse files
Alias OpenSSL SECLEVEL directives to ALL
1 parent 7c47081 commit 498c740

File tree

3 files changed

+16
-83
lines changed

3 files changed

+16
-83
lines changed

ssl/ssl_cipher.cc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,13 +1187,16 @@ static bool ssl_cipher_process_rulestr(const char *rule_str,
11871187

11881188
// Ok, we have the rule, now apply it.
11891189
if (rule == CIPHER_SPECIAL) {
1190-
if (buf_len != 8 || strncmp(buf, "STRENGTH", 8) != 0) {
1190+
if (buf_len == 8 && strncmp(buf, "STRENGTH", 8) != 0) {
1191+
if (!ssl_cipher_strength_sort(head_p, tail_p)) {
1192+
return false;
1193+
}
1194+
} else if (!strict && buf_len == 8 && strncmp(buf, "SECLEVEL", 8) != 0) {
1195+
// pass
1196+
} else {
11911197
OPENSSL_PUT_ERROR(SSL, SSL_R_INVALID_COMMAND);
11921198
return false;
11931199
}
1194-
if (!ssl_cipher_strength_sort(head_p, tail_p)) {
1195-
return false;
1196-
}
11971200

11981201
// We do not support any "multi" options together with "@", so throw away
11991202
// the rest of the command, if any left, until end or ':' is found.
@@ -1219,6 +1222,10 @@ static const char *kKnownKeywordFilterRulesMappingToDefault[] = {
12191222
"DEFAULT",
12201223
"FIPS",
12211224
"HIGH",
1225+
"SECLEVEL=0",
1226+
"SECLEVEL=1",
1227+
"SECLEVEL=2",
1228+
"SECLEVEL=3",
12221229
};
12231230

12241231
static bool is_known_default_alias_keyword_filter_rule(const char *rule,

tests/ci/integration/python_patch/main/aws-lc-cpython.patch

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,12 @@
1-
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
2-
index 6e63a88..7dc83d7 100644
3-
--- a/Lib/test/test_httplib.py
4-
+++ b/Lib/test/test_httplib.py
5-
@@ -2066,7 +2066,7 @@ def test_host_port(self):
6-
7-
def test_tls13_pha(self):
8-
import ssl
9-
- if not ssl.HAS_TLSv1_3:
10-
+ if not ssl.HAS_TLSv1_3 or "AWS-LC" in ssl.OPENSSL_VERSION:
11-
self.skipTest('TLS 1.3 support required')
12-
# just check status of PHA flag
13-
h = client.HTTPSConnection('localhost', 443)
141
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
152
index 0e50d09..f4b7b3c 100644
163
--- a/Lib/test/test_ssl.py
174
+++ b/Lib/test/test_ssl.py
18-
@@ -41,6 +41,7 @@
19-
from ssl import Purpose, TLSVersion, _TLSContentType, _TLSMessageType, _TLSAlertType
20-
21-
Py_DEBUG_WIN32 = support.Py_DEBUG and sys.platform == 'win32'
22-
+Py_OPENSSL_IS_AWSLC = "AWS-LC" in ssl.OPENSSL_VERSION
23-
24-
PROTOCOLS = sorted(ssl._PROTOCOL_NAMES)
25-
HOST = socket_helper.HOST
26-
@@ -174,7 +175,7 @@ def is_ubuntu():
27-
except FileNotFoundError:
28-
return False
29-
30-
-if is_ubuntu():
31-
+if is_ubuntu() and not Py_OPENSSL_IS_AWSLC:
32-
def seclevel_workaround(*ctxs):
33-
""""Lower security level to '1' and allow all ciphers for TLS 1.0/1"""
34-
for ctx in ctxs:
35-
@@ -4001,6 +4002,7 @@ def test_no_legacy_server_connect(self):
5+
@@ -4034,6 +4034,7 @@ def test_no_legacy_server_connect(self):
366
sni_name=hostname)
37-
7+
388
@unittest.skipIf(Py_DEBUG_WIN32, "Avoid mixing debug/release CRT on Windows")
39-
+ @unittest.skipIf(Py_OPENSSL_IS_AWSLC, "AWS-LC doesn't support (FF)DHE")
9+
+ @unittest.skipIf("AWS-LC" in ssl.OPENSSL_VERSION, "AWS-LC doesn't support")
4010
def test_dh_params(self):
4111
# Check we can get a connection with ephemeral Diffie-Hellman
4212
client_context, server_context, hostname = testing_context()
@@ -74,50 +44,6 @@ index 0e50d09..f4b7b3c 100644
7444
server_context.minimum_version = ssl.TLSVersion.TLSv1_3
7545
server_context.set_ciphers('PSK')
7646
server_context.set_psk_server_callback(server_callback, identity_hint)
77-
@@ -4461,7 +4463,10 @@ def server_callback(identity):
78-
s.connect((HOST, server.port))
79-
80-
81-
-@unittest.skipUnless(has_tls_version('TLSv1_3'), "Test needs TLS 1.3")
82-
+@unittest.skipUnless(
83-
+ has_tls_version('TLSv1_3') and not Py_OPENSSL_IS_AWSLC,
84-
+ "Test needs TLS 1.3; AWS-LC doesn't support PHA"
85-
+)
86-
class TestPostHandshakeAuth(unittest.TestCase):
87-
def test_pha_setter(self):
88-
protocols = [
89-
@@ -4737,6 +4742,31 @@ def test_internal_chain_server(self):
90-
self.assertEqual(res, b'\x02\n')
91-
92-
93-
+@unittest.skipUnless(Py_OPENSSL_IS_AWSLC, "Only test this against AWS-LC")
94-
+class TestPostHandshakeAuthAwsLc(unittest.TestCase):
95-
+ def test_pha(self):
96-
+ protocols = [
97-
+ ssl.PROTOCOL_TLS_SERVER, ssl.PROTOCOL_TLS_CLIENT
98-
+ ]
99-
+ for protocol in protocols:
100-
+ client_ctx, server_ctx, hostname = testing_context()
101-
+ client_ctx.load_cert_chain(SIGNED_CERTFILE)
102-
+ self.assertEqual(client_ctx.post_handshake_auth, None)
103-
+ with self.assertRaises(AttributeError):
104-
+ client_ctx.post_handshake_auth = True
105-
+ with self.assertRaises(AttributeError):
106-
+ server_ctx.post_handshake_auth = True
107-
+
108-
+ with ThreadedEchoServer(context=server_ctx) as server:
109-
+ with client_ctx.wrap_socket(
110-
+ socket.socket(),
111-
+ server_hostname=hostname
112-
+ ) as ssock:
113-
+ ssock.connect((HOST, server.port))
114-
+ with self.assertRaises(NotImplementedError):
115-
+ ssock.verify_client_post_handshake()
116-
+
117-
+
118-
HAS_KEYLOG = hasattr(ssl.SSLContext, 'keylog_filename')
119-
requires_keylog = unittest.skipUnless(
120-
HAS_KEYLOG, 'test requires OpenSSL 1.1.1 with keylog callback')
12147
diff --git a/Modules/Setup b/Modules/Setup
12248
index cd1cf24..53bcc4c 100644
12349
--- a/Modules/Setup

tests/ci/integration/run_python_integration.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@ function python_patch() {
184184
echo "No patch for ${branch}!"
185185
exit 1
186186
fi
187-
git clone https://github.com/python/cpython.git ${src_dir} \
187+
git clone https://github.com/WillChilds-Klein/cpython.git ${src_dir} \
188188
--depth 1 \
189-
--branch ${branch}
189+
--branch ssl-add-has-pha-property
190190
for patchfile in $(find -L ${patch_dir} -type f -name '*.patch'); do
191191
echo "Apply patch ${patchfile}..."
192192
cat ${patchfile} \

0 commit comments

Comments
 (0)