@@ -23,12 +23,15 @@ class Urllib3HttpConnection(Connection):
23
23
:arg ssl_version: version of the SSL protocol to use. Choices are:
24
24
SSLv23 (default) SSLv2 SSLv3 TLSv1 (see ``PROTOCOL_*`` constants in the
25
25
``ssl`` module for exact options for your environment).
26
+ :arg ssl_assert_hostname: use hostname verification if not `False`
27
+ :arg ssl_assert_fingerprint: verify the supplied certificate fingerprint if not `None`
26
28
:arg maxsize: the maximum number of connections which will be kept open to
27
29
this host.
28
30
"""
29
31
def __init__ (self , host = 'localhost' , port = 9200 , http_auth = None ,
30
32
use_ssl = False , verify_certs = False , ca_certs = None , client_cert = None ,
31
- ssl_version = None , maxsize = 10 , ** kwargs ):
33
+ ssl_version = None , ssl_assert_hostname = None , ssl_assert_fingerprint = None ,
34
+ maxsize = 10 , ** kwargs ):
32
35
33
36
super (Urllib3HttpConnection , self ).__init__ (host = host , port = port , ** kwargs )
34
37
self .headers = urllib3 .make_headers (keep_alive = True )
@@ -41,12 +44,18 @@ def __init__(self, host='localhost', port=9200, http_auth=None,
41
44
kw = {}
42
45
if use_ssl :
43
46
pool_class = urllib3 .HTTPSConnectionPool
44
- kw ['ssl_version' ] = ssl_version
47
+ kw .update ({
48
+ 'ssl_version' : ssl_version ,
49
+ 'assert_hostname' : ssl_assert_hostname ,
50
+ 'assert_fingerprint' : ssl_assert_fingerprint ,
51
+ })
45
52
46
53
if verify_certs :
47
- kw ['cert_reqs' ] = 'CERT_REQUIRED'
48
- kw ['ca_certs' ] = ca_certs
49
- kw ['cert_file' ] = client_cert
54
+ kw .update ({
55
+ 'cert_reqs' : 'CERT_REQUIRED' ,
56
+ 'ca_certs' : ca_certs ,
57
+ 'cert_file' : client_cert ,
58
+ })
50
59
elif ca_certs :
51
60
raise ImproperlyConfigured ("You cannot pass CA certificates when verify SSL is off." )
52
61
else :
0 commit comments