Skip to content

Commit 4d0a3d9

Browse files
committed
Merge pull request #1039 from docker/felixonmars-backports
Use backports.ssl_match_hostname
2 parents d80e75f + c76a914 commit 4d0a3d9

File tree

5 files changed

+14
-137
lines changed

5 files changed

+14
-137
lines changed

docker/ssladapter/ssl_match_hostname.py

Lines changed: 0 additions & 130 deletions
This file was deleted.

docker/ssladapter/ssladapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Monkey-patching match_hostname with a version that supports
1919
# IP-address checking. Not necessary for Python 3.5 and above
2020
if sys.version_info[0] < 3 or sys.version_info[1] < 5:
21-
from .ssl_match_hostname import match_hostname
21+
from backports.ssl_match_hostname import match_hostname
2222
urllib3.connection.match_hostname = match_hostname
2323

2424

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
requests==2.5.3
22
six>=1.4.0
33
websocket-client==0.32.0
4-
py2-ipaddress==3.4.1 ; python_version < '3.2'
4+
backports.ssl_match_hostname>=3.5 ; python_version < '3.5'
5+
ipaddress==1.0.16 ; python_version < '3.3'

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22
import os
3-
import sys
43
from setuptools import setup
54

65
ROOT_DIR = os.path.dirname(__file__)
@@ -13,7 +12,8 @@
1312
]
1413

1514
extras_require = {
16-
':python_version < "3"': 'py2-ipaddress >= 3.4.1',
15+
':python_version < "3.5"': 'backports.ssl_match_hostname >= 3.5',
16+
':python_version < "3.3"': 'ipaddress >= 1.0.16',
1717
}
1818

1919
exec(open('docker/version.py').read())

tests/unit/ssladapter_test.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
from docker.ssladapter import ssladapter
2-
from docker.ssladapter.ssl_match_hostname import (
3-
match_hostname, CertificateError
4-
)
2+
3+
try:
4+
from backports.ssl_match_hostname import (
5+
match_hostname, CertificateError
6+
)
7+
except ImportError:
8+
from ssl import (
9+
match_hostname, CertificateError
10+
)
511

612
try:
713
from ssl import OP_NO_SSLv3, OP_NO_SSLv2, OP_NO_TLSv1

0 commit comments

Comments
 (0)