|
48 | 48 |
|
49 | 49 | PROTOCOLS = sorted(ssl._PROTOCOL_NAMES) |
50 | 50 | HOST = socket_helper.HOST |
| 51 | +IS_AWS_LC = "AWS-LC" in ssl.OPENSSL_VERSION |
51 | 52 | IS_OPENSSL_3_0_0 = ssl.OPENSSL_VERSION_INFO >= (3, 0, 0) |
52 | 53 | CAN_GET_SELECTED_OPENSSL_GROUP = ssl.OPENSSL_VERSION_INFO >= (3, 2) |
53 | 54 | CAN_IGNORE_UNKNOWN_OPENSSL_GROUPS = ssl.OPENSSL_VERSION_INFO >= (3, 3) |
54 | 55 | CAN_GET_AVAILABLE_OPENSSL_GROUPS = ssl.OPENSSL_VERSION_INFO >= (3, 5) |
55 | 56 | CAN_GET_AVAILABLE_OPENSSL_SIGALGS = ssl.OPENSSL_VERSION_INFO >= (3, 4) |
56 | | -CAN_SET_CLIENT_SIGALGS = "AWS-LC" not in ssl.OPENSSL_VERSION |
| 57 | +CAN_SET_CLIENT_SIGALGS = not IS_AWS_LC |
57 | 58 | CAN_IGNORE_UNKNOWN_OPENSSL_SIGALGS = ssl.OPENSSL_VERSION_INFO >= (3, 3) |
58 | 59 | CAN_GET_SELECTED_OPENSSL_SIGALG = ssl.OPENSSL_VERSION_INFO >= (3, 5) |
59 | 60 | PY_SSL_DEFAULT_CIPHERS = sysconfig.get_config_var('PY_SSL_DEFAULT_CIPHERS') |
@@ -1579,10 +1580,18 @@ def sni_callback(sock, servername, ctx): pass |
1579 | 1580 | # Try to continue the server's handshake by directly using |
1580 | 1581 | # the internal SSL object. The latter is a weak reference |
1581 | 1582 | # stored in the server context and has now a dead owner. |
1582 | | - with self.assertRaisesRegex(ssl.SSLError, "callback failed") as cm: |
| 1583 | + with self.assertRaises(ssl.SSLError) as cm: |
1583 | 1584 | server_impl.do_handshake() |
1584 | 1585 | # The SNI C callback raised an exception before calling our callback. |
1585 | 1586 | sni_callback.assert_not_called() |
| 1587 | + |
| 1588 | + # In AWS-LC, any handshake failures reports SSL_R_PARSE_TLSEXT, |
| 1589 | + # while OpenSSL uses SSL_R_CALLBACK_FAILED on SNI callback failures. |
| 1590 | + if IS_AWS_LC: |
| 1591 | + libssl_error_reason = "PARSE_TLSEXT" |
| 1592 | + else: |
| 1593 | + libssl_error_reason = "callback failed" |
| 1594 | + self.assertIn(libssl_error_reason, str(cm.exception)) |
1586 | 1595 | self.assertEqual(cm.exception.errno, ssl.SSL_ERROR_SSL) |
1587 | 1596 |
|
1588 | 1597 | def test_sni_callback_refcycle(self): |
|
0 commit comments