111111
112112 **ca_bytes** (`bytes`): Override default trust store with CA certificates from these PEM formatted bytes.
113113
114+ **cipher_pref** (:class:`awscrt.io.TlsCipherPref`): Cipher preference to use for TLS connection. Default is `TlsCipherPref.DEFAULT`.
115+
114116 **enable_metrics_collection** (`bool`): Whether to send the SDK version number in the CONNECT packet.
115117 Default is True.
116118
@@ -181,8 +183,11 @@ def _builder(
181183 use_websockets = False ,
182184 websocket_handshake_transform = None ,
183185 use_custom_authorizer = False ,
186+ cipher_pref = awscrt .io .TlsCipherPref .DEFAULT ,
184187 ** kwargs ):
185188
189+ assert isinstance (cipher_pref , awscrt .io .TlsCipherPref )
190+
186191 ca_bytes = _get (kwargs , 'ca_bytes' )
187192 ca_filepath = _get (kwargs , 'ca_filepath' )
188193 ca_dirpath = _get (kwargs , 'ca_dirpath' )
@@ -202,6 +207,8 @@ def _builder(
202207 if port == 443 and awscrt .io .is_alpn_available () and use_custom_authorizer is False :
203208 tls_ctx_options .alpn_list = ['http/1.1' ] if use_websockets else ['x-amzn-mqtt-ca' ]
204209
210+ tls_ctx_options .cipher_pref = cipher_pref
211+
205212 socket_options = awscrt .io .SocketOptions ()
206213 socket_options .connect_timeout_ms = _get (kwargs , 'tcp_connect_timeout_ms' , 5000 )
207214 # These have been inconsistent between keepalive/keep_alive. Resolve both for now to ease transition.
@@ -350,6 +357,7 @@ def mtls_with_pkcs11(*,
350357
351358 return _builder (tls_ctx_options , ** kwargs )
352359
360+
353361def mtls_with_pkcs12 (* ,
354362 pkcs12_filepath : str ,
355363 pkcs12_password : str ,
@@ -552,6 +560,7 @@ def direct_with_custom_authorizer(
552560 use_websockets = False ,
553561 ** kwargs )
554562
563+
555564def websockets_with_custom_authorizer (
556565 region = None ,
557566 credentials_provider = None ,
@@ -590,7 +599,7 @@ def websockets_with_custom_authorizer(
590599 auth_authorizer_signature (`str`): The digital signature of the token value in the `auth_token_value`
591600 parameter. The signature must be based on the private key associated with the custom authorizer. The
592601 signature must be base64 encoded.
593- Required if the custom authorizer has signing enabled.
602+ Required if the custom authorizer has signing enabled.
594603
595604 auth_token_key_name (`str`): Key used to extract the custom authorizer token from MQTT username query-string
596605 properties.
@@ -616,15 +625,15 @@ def websockets_with_custom_authorizer(
616625
617626
618627def _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 :
628+ auth_authorizer_name = None ,
629+ auth_authorizer_signature = None ,
630+ auth_password = None ,
631+ auth_token_key_name = None ,
632+ auth_token_value = None ,
633+ use_websockets = False ,
634+ websockets_credentials_provider = None ,
635+ websockets_region = None ,
636+ ** kwargs ) -> awscrt .mqtt .Connection :
628637 """
629638 Helper function that contains the setup needed for custom authorizers
630639 """
@@ -657,7 +666,7 @@ def _with_custom_authorizer(auth_username=None,
657666 kwargs ["password" ] = auth_password
658667
659668 tls_ctx_options = awscrt .io .TlsContextOptions ()
660- if use_websockets == False :
669+ if not use_websockets :
661670 kwargs ["port" ] = 443
662671 tls_ctx_options .alpn_list = ["mqtt" ]
663672
0 commit comments