@@ -258,7 +258,11 @@ def _builder(
258258 )
259259
260260
261- def mtls_from_path (cert_filepath , pri_key_filepath , ** kwargs ) -> awscrt .mqtt .Connection :
261+ def mtls_from_path (
262+ cert_filepath ,
263+ pri_key_filepath ,
264+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
265+ ** kwargs ) -> awscrt .mqtt .Connection :
262266 """
263267 This builder creates an :class:`awscrt.mqtt.Connection`, configured for an mTLS MQTT connection to AWS IoT.
264268 TLS arguments are passed as filepaths.
@@ -273,10 +277,15 @@ def mtls_from_path(cert_filepath, pri_key_filepath, **kwargs) -> awscrt.mqtt.Con
273277 """
274278 _check_required_kwargs (** kwargs )
275279 tls_ctx_options = awscrt .io .TlsContextOptions .create_client_with_mtls_from_path (cert_filepath , pri_key_filepath )
280+ tls_ctx_options .cipher_pref = cipher_suite
276281 return _builder (tls_ctx_options , ** kwargs )
277282
278283
279- def mtls_from_bytes (cert_bytes , pri_key_bytes , ** kwargs ) -> awscrt .mqtt .Connection :
284+ def mtls_from_bytes (
285+ cert_bytes ,
286+ pri_key_bytes ,
287+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
288+ ** kwargs ) -> awscrt .mqtt .Connection :
280289 """
281290 This builder creates an :class:`awscrt.mqtt.Connection`, configured for an mTLS MQTT connection to AWS IoT.
282291 TLS arguments are passed as in-memory bytes.
@@ -291,6 +300,7 @@ def mtls_from_bytes(cert_bytes, pri_key_bytes, **kwargs) -> awscrt.mqtt.Connecti
291300 """
292301 _check_required_kwargs (** kwargs )
293302 tls_ctx_options = awscrt .io .TlsContextOptions .create_client_with_mtls (cert_bytes , pri_key_bytes )
303+ tls_ctx_options .cipher_pref = cipher_suite
294304 return _builder (tls_ctx_options , ** kwargs )
295305
296306
@@ -302,6 +312,7 @@ def mtls_with_pkcs11(*,
302312 private_key_label : str = None ,
303313 cert_filepath : str = None ,
304314 cert_bytes = None ,
315+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
305316 ** kwargs ) -> awscrt .mqtt .Connection :
306317 """
307318 This builder creates an :class:`awscrt.mqtt.Connection`, configured for an mTLS MQTT connection to AWS IoT,
@@ -347,12 +358,15 @@ def mtls_with_pkcs11(*,
347358 private_key_label = private_key_label ,
348359 cert_file_path = cert_filepath ,
349360 cert_file_contents = cert_bytes )
361+ tls_ctx_options .cipher_pref = cipher_suite
350362
351363 return _builder (tls_ctx_options , ** kwargs )
352364
365+
353366def mtls_with_pkcs12 (* ,
354367 pkcs12_filepath : str ,
355368 pkcs12_password : str ,
369+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
356370 ** kwargs ) -> awscrt .mqtt .Connection :
357371 """
358372 This builder creates an :class:`awscrt.mqtt.Connection`, configured for an mTLS MQTT connection to AWS IoT,
@@ -373,11 +387,13 @@ def mtls_with_pkcs12(*,
373387 tls_ctx_options = awscrt .io .TlsContextOptions .create_client_with_mtls_pkcs12 (
374388 pkcs12_filepath = pkcs12_filepath ,
375389 pkcs12_password = pkcs12_password )
390+ tls_ctx_options .cipher_suite = cipher_suite
376391 return _builder (tls_ctx_options , ** kwargs )
377392
378393
379394def mtls_with_windows_cert_store_path (* ,
380395 cert_store_path : str ,
396+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
381397 ** kwargs ) -> awscrt .mqtt .Connection :
382398 """
383399 This builder creates an :class:`awscrt.mqtt.Connection`, configured for an mTLS MQTT connection to AWS IoT,
@@ -396,6 +412,7 @@ def mtls_with_windows_cert_store_path(*,
396412 _check_required_kwargs (** kwargs )
397413
398414 tls_ctx_options = awscrt .io .TlsContextOptions .create_client_with_mtls_windows_cert_store_path (cert_store_path )
415+ tls_ctx_options .cipher_pref = cipher_suite
399416
400417 return _builder (tls_ctx_options , ** kwargs )
401418
@@ -404,6 +421,7 @@ def websockets_with_default_aws_signing(
404421 region ,
405422 credentials_provider ,
406423 websocket_proxy_options = None ,
424+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
407425 ** kwargs ) -> awscrt .mqtt .Connection :
408426 """
409427 This builder creates an :class:`awscrt.mqtt.Connection`, configured for an MQTT connection over websockets to AWS IoT.
@@ -441,12 +459,17 @@ def _sign_websocket_handshake_request(transform_args, **kwargs):
441459 except Exception as e :
442460 transform_args .set_done (e )
443461
444- return websockets_with_custom_handshake (_sign_websocket_handshake_request , websocket_proxy_options , ** kwargs )
462+ return websockets_with_custom_handshake (
463+ _sign_websocket_handshake_request ,
464+ cipher_suite ,
465+ websocket_proxy_options ,
466+ ** kwargs )
445467
446468
447469def websockets_with_custom_handshake (
448470 websocket_handshake_transform ,
449471 websocket_proxy_options = None ,
472+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
450473 ** kwargs ) -> awscrt .mqtt .Connection :
451474 """
452475 This builder creates an :class:`awscrt.mqtt.Connection`, configured for an MQTT connection over websockets,
@@ -474,6 +497,7 @@ def websockets_with_custom_handshake(
474497 """
475498 _check_required_kwargs (** kwargs )
476499 tls_ctx_options = awscrt .io .TlsContextOptions ()
500+ tls_ctx_options .cipher_pref = cipher_suite
477501 return _builder (tls_ctx_options = tls_ctx_options ,
478502 use_websockets = True ,
479503 websocket_handshake_transform = websocket_handshake_transform ,
@@ -505,6 +529,7 @@ def direct_with_custom_authorizer(
505529 auth_password = None ,
506530 auth_token_key_name = None ,
507531 auth_token_value = None ,
532+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
508533 ** kwargs ) -> awscrt .mqtt .Connection :
509534 """
510535 This builder creates an :class:`awscrt.mqtt.Connection`, configured for an MQTT connection using a custom
@@ -550,8 +575,10 @@ def direct_with_custom_authorizer(
550575 auth_token_key_name = auth_token_key_name ,
551576 auth_token_value = auth_token_value ,
552577 use_websockets = False ,
578+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
553579 ** kwargs )
554580
581+
555582def websockets_with_custom_authorizer (
556583 region = None ,
557584 credentials_provider = None ,
@@ -561,6 +588,7 @@ def websockets_with_custom_authorizer(
561588 auth_password = None ,
562589 auth_token_key_name = None ,
563590 auth_token_value = None ,
591+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
564592 ** kwargs ) -> awscrt .mqtt .Connection :
565593 """
566594 This builder creates an :class:`awscrt.mqtt.Connection`, configured for an MQTT connection using a custom
@@ -590,7 +618,7 @@ def websockets_with_custom_authorizer(
590618 auth_authorizer_signature (`str`): The digital signature of the token value in the `auth_token_value`
591619 parameter. The signature must be based on the private key associated with the custom authorizer. The
592620 signature must be base64 encoded.
593- Required if the custom authorizer has signing enabled.
621+ Required if the custom authorizer has signing enabled.
594622
595623 auth_token_key_name (`str`): Key used to extract the custom authorizer token from MQTT username query-string
596624 properties.
@@ -612,19 +640,21 @@ def websockets_with_custom_authorizer(
612640 use_websockets = True ,
613641 websockets_region = region ,
614642 websockets_credentials_provider = credentials_provider ,
643+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
615644 ** kwargs )
616645
617646
618647def _with_custom_authorizer (auth_username = None ,
619- auth_authorizer_name = None ,
620- auth_authorizer_signature = None ,
621- auth_password = None ,
622- auth_token_key_name = None ,
623- auth_token_value = None ,
624- use_websockets = False ,
625- websockets_credentials_provider = None ,
626- websockets_region = None ,
627- ** kwargs ) -> awscrt .mqtt .Connection :
648+ auth_authorizer_name = None ,
649+ auth_authorizer_signature = None ,
650+ auth_password = None ,
651+ auth_token_key_name = None ,
652+ auth_token_value = None ,
653+ use_websockets = False ,
654+ websockets_credentials_provider = None ,
655+ websockets_region = None ,
656+ cipher_suite : awscrt .io .TlsCipherPref = awscrt .io .TlsCipherPref .DEFAULT ,
657+ ** kwargs ) -> awscrt .mqtt .Connection :
628658 """
629659 Helper function that contains the setup needed for custom authorizers
630660 """
@@ -657,7 +687,8 @@ def _with_custom_authorizer(auth_username=None,
657687 kwargs ["password" ] = auth_password
658688
659689 tls_ctx_options = awscrt .io .TlsContextOptions ()
660- if use_websockets == False :
690+ tls_ctx_options .cipher_pref = cipher_suite
691+ if not use_websockets :
661692 kwargs ["port" ] = 443
662693 tls_ctx_options .alpn_list = ["mqtt" ]
663694
0 commit comments