@@ -143,9 +143,11 @@ class AMQPClient(object): # pylint: disable=too-many-instance-attributes
143
143
If port is not specified in the `custom_endpoint_address`, by default port 443 will be used.
144
144
:paramtype custom_endpoint_address: str
145
145
:keyword connection_verify: Path to the custom CA_BUNDLE file of the SSL certificate which is used to
146
- authenticate the identity of the connection endpoint.
147
- Default is None in which case `certifi.where()` will be used.
146
+ authenticate the identity of the connection endpoint. Ignored if ssl_context passed in. Default is None
147
+ in which case `certifi.where()` will be used.
148
148
:paramtype connection_verify: str
149
+ :keyword ssl_context: An instance of ssl.SSLContext to be used. If this is specified, connection_verify is ignored.
150
+ :paramtype ssl_context: ssl.SSLContext or None
149
151
:keyword float socket_timeout: The maximum time in seconds that the underlying socket in the transport should
150
152
wait when reading or writing data before timing out. The default value is 0.2 (for transport type Amqp),
151
153
and 1 for transport type AmqpOverWebsocket.
@@ -201,7 +203,13 @@ def __init__(self, hostname, **kwargs):
201
203
202
204
# Custom Endpoint
203
205
self ._custom_endpoint_address = kwargs .get ("custom_endpoint_address" )
204
- self ._connection_verify = kwargs .get ("connection_verify" )
206
+ connection_verify = kwargs .get ("connection_verify" )
207
+ ssl_context = kwargs .get ("ssl_context" )
208
+ self ._ssl_opts = {}
209
+ if ssl_context :
210
+ self ._ssl_opts ["context" ] = ssl_context
211
+ else : # str or None
212
+ self ._ssl_opts ["ca_certs" ] = connection_verify or certifi .where ()
205
213
206
214
# Emulator
207
215
self ._use_tls : bool = kwargs .get ("use_tls" , True )
@@ -306,7 +314,7 @@ def open(self, connection=None):
306
314
self ._connection = Connection (
307
315
"amqps://" + self ._hostname if self ._use_tls else "amqp://" + self ._hostname ,
308
316
sasl_credential = self ._auth .sasl ,
309
- ssl_opts = { "ca_certs" : self ._connection_verify or certifi . where ()} ,
317
+ ssl_opts = self ._ssl_opts ,
310
318
container_id = self ._name ,
311
319
max_frame_size = self ._max_frame_size ,
312
320
channel_max = self ._channel_max ,
@@ -556,9 +564,11 @@ class SendClient(AMQPClient):
556
564
If port is not specified in the `custom_endpoint_address`, by default port 443 will be used.
557
565
:paramtype custom_endpoint_address: str
558
566
:keyword connection_verify: Path to the custom CA_BUNDLE file of the SSL certificate which is used to
559
- authenticate the identity of the connection endpoint.
560
- Default is None in which case `certifi.where()` will be used.
567
+ authenticate the identity of the connection endpoint. Ignored if ssl_context passed in. Default is None
568
+ in which case `certifi.where()` will be used.
561
569
:paramtype connection_verify: str
570
+ :keyword ssl_context: An instance of ssl.SSLContext to be used. If this is specified, connection_verify is ignored.
571
+ :paramtype ssl_context: ssl.SSLContext or None
562
572
"""
563
573
564
574
def __init__ (self , hostname , target , ** kwargs ):
@@ -779,9 +789,11 @@ class ReceiveClient(AMQPClient): # pylint:disable=too-many-instance-attributes
779
789
If port is not specified in the `custom_endpoint_address`, by default port 443 will be used.
780
790
:paramtype custom_endpoint_address: str
781
791
:keyword connection_verify: Path to the custom CA_BUNDLE file of the SSL certificate which is used to
782
- authenticate the identity of the connection endpoint.
783
- Default is None in which case `certifi.where()` will be used.
792
+ authenticate the identity of the connection endpoint. Ignored if ssl_context passed in. Default is None
793
+ in which case `certifi.where()` will be used.
784
794
:paramtype connection_verify: str
795
+ :keyword ssl_context: An instance of ssl.SSLContext to be used. If this is specified, connection_verify is ignored.
796
+ :paramtype ssl_context: ssl.SSLContext or None
785
797
"""
786
798
787
799
def __init__ (self , hostname , source , ** kwargs ):
0 commit comments