Skip to content

Commit 4a456f3

Browse files
authored
noCertificateRevocation option binding (#748)
1 parent 471a99a commit 4a456f3

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

awscrt/io.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ class TlsContextOptions:
309309
System defaults are used by default.
310310
cipher_pref (TlsCipherPref): The TLS Cipher Preference to use. System defaults are used by default.
311311
verify_peer (bool): Whether to validate the peer's x.509 certificate.
312+
no_certificate_revocation (bool): Set to true to disable certificate revocation checking during TLS negotiation.
313+
On Windows (SChannel), this prevents the TLS handshake from making outbound network calls
314+
to CRL/OCSP revocation endpoints, which can block for minutes when the endpoints are unreachable
315+
(e.g., in private subnets without internet access).
316+
On Linux (s2n), this disables validation of OCSP stapled responses provided by the server.
317+
On Apple platforms, this is a no-op as revocation checking is not enabled by default.
312318
alpn_list (Optional[List[str]]): If set, names to use in Application Layer
313319
Protocol Negotiation (ALPN). ALPN is not supported on all systems,
314320
see :meth:`is_alpn_available()`. This can be customized per connection,
@@ -325,6 +331,7 @@ class TlsContextOptions:
325331
'pkcs12_filepath',
326332
'pkcs12_password',
327333
'verify_peer',
334+
'no_certificate_revocation',
328335
'_pkcs11_lib',
329336
'_pkcs11_user_pin',
330337
'_pkcs11_slot_id',
@@ -343,6 +350,7 @@ def __init__(self):
343350
self.min_tls_ver = TlsVersion.DEFAULT
344351
self.cipher_pref = TlsCipherPref.DEFAULT
345352
self.verify_peer = True
353+
self.no_certificate_revocation = False
346354

347355
@staticmethod
348356
def create_client_with_mtls_from_path(cert_filepath, pk_filepath):
@@ -627,6 +635,7 @@ def __init__(self, options):
627635
options.pkcs12_filepath,
628636
options.pkcs12_password,
629637
options.verify_peer,
638+
options.no_certificate_revocation,
630639
options._pkcs11_lib,
631640
options._pkcs11_user_pin,
632641
options._pkcs11_slot_id,

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ def determine_generator_args(cmake_version=None, windows_sdk_version=None):
174174
# This technique may not work with customized VS install paths.
175175
# An alternative would be to utilize private python calls:
176176
# (distutils._msvccompiler._find_vc2017() and _find_vc2015()).
177-
if '\\Microsoft Visual Studio\\2022' in compiler.cc:
177+
if '\\Microsoft Visual Studio\\18' in compiler.cc:
178+
vs_version = 18
179+
vs_year = 2026
180+
elif '\\Microsoft Visual Studio\\2022' in compiler.cc:
178181
vs_version = 17
179182
vs_year = 2022
180183
elif '\\Microsoft Visual Studio\\2019' in compiler.cc:

source/io.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ PyObject *aws_py_client_tls_ctx_new(PyObject *self, PyObject *args) {
426426
Py_ssize_t private_key_buffer_len;
427427
const char *pkcs12_filepath;
428428
const char *pkcs12_password;
429-
int verify_peer; /* p - boolean predicate */
429+
int verify_peer;
430+
int no_certificate_revocation;
430431
PyObject *py_pkcs11_lib;
431432
const char *pkcs11_user_pin;
432433
Py_ssize_t pkcs11_user_pin_len;
@@ -443,7 +444,7 @@ PyObject *aws_py_client_tls_ctx_new(PyObject *self, PyObject *args) {
443444

444445
if (!PyArg_ParseTuple(
445446
args,
446-
"iizz#zz#z#zzpOz#Oz#z#z#z#z",
447+
"iizz#zz#z#zzppOz#Oz#z#z#z#z",
447448
/* i */ &min_tls_version,
448449
/* i */ &cipher_pref,
449450
/* z */ &ca_dirpath,
@@ -457,6 +458,7 @@ PyObject *aws_py_client_tls_ctx_new(PyObject *self, PyObject *args) {
457458
/* z */ &pkcs12_filepath,
458459
/* z */ &pkcs12_password,
459460
/* p */ &verify_peer,
461+
/* p */ &no_certificate_revocation,
460462
/* O */ &py_pkcs11_lib,
461463
/* z */ &pkcs11_user_pin,
462464
/* # */ &pkcs11_user_pin_len,
@@ -560,6 +562,8 @@ PyObject *aws_py_client_tls_ctx_new(PyObject *self, PyObject *args) {
560562
}
561563

562564
ctx_options.verify_peer = (bool)verify_peer;
565+
ctx_options.no_certificate_revocation = (bool)no_certificate_revocation;
566+
563567
struct aws_tls_ctx *tls_ctx = aws_tls_client_ctx_new(allocator, &ctx_options);
564568
if (!tls_ctx) {
565569
PyErr_SetAwsLastError();

0 commit comments

Comments
 (0)