Skip to content

Commit 01f8085

Browse files
committed
bind no_certificate_revocation option
1 parent f441058 commit 01f8085

2 files changed

Lines changed: 14 additions & 1 deletion

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,

source/io.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ PyObject *aws_py_client_tls_ctx_new(PyObject *self, PyObject *args) {
427427
const char *pkcs12_filepath;
428428
const char *pkcs12_password;
429429
int verify_peer; /* p - boolean predicate */
430+
int no_certificate_revocation; /* p - boolean predicate */
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)