Skip to content

Commit 7773bdf

Browse files
authored
Revert "Feature/wildcard certs hostname" (#150)
1 parent e9e17b0 commit 7773bdf

File tree

4 files changed

+3
-54
lines changed

4 files changed

+3
-54
lines changed

rethinkdb/gevent_net/net_gevent.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from rethinkdb import net, ql2_pb2
2727
from rethinkdb.errors import ReqlAuthError, ReqlCursorEmpty, ReqlDriverError, ReqlTimeoutError, RqlDriverError, \
2828
RqlTimeoutError
29-
from rethinkdb.helpers import get_hostname_for_ssl_match
3029
from rethinkdb.logger import default_logger
3130

3231
__all__ = ['Connection']
@@ -104,10 +103,7 @@ def __init__(self, parent):
104103
self._socket.close()
105104
raise ReqlDriverError("SSL handshake failed (see server log for more information): %s" % str(exc))
106105
try:
107-
ssl.match_hostname(
108-
self._socket.getpeercert(),
109-
hostname=get_hostname_for_ssl_match(self.host)
110-
)
106+
ssl.match_hostname(self._socket.getpeercert(), hostname=self.host)
111107
except ssl.CertificateError:
112108
self._socket.close()
113109
raise

rethinkdb/helpers.py

-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
import six
22

3-
43
def decode_utf8(string, encoding='utf-8'):
54
if hasattr(string, 'decode'):
65
return string.decode(encoding)
76

87
return string
98

10-
119
def chain_to_bytes(*strings):
1210
return b''.join([six.b(string) if isinstance(string, six.string_types) else string for string in strings])
13-
14-
15-
def get_hostname_for_ssl_match(hostname):
16-
parts = hostname.split('.')
17-
18-
if len(parts) < 3:
19-
return hostname
20-
21-
parts[0] = '*'
22-
return '.'.join(parts)

rethinkdb/net.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
ReqlTimeoutError,
4545
ReqlUserError)
4646
from rethinkdb.handshake import HandshakeV1_0
47-
from rethinkdb.helpers import get_hostname_for_ssl_match
4847
from rethinkdb.logger import default_logger
4948

5049
__all__ = ['Connection', 'Cursor', 'DEFAULT_PORT', 'DefaultConnection', 'make_connection']
@@ -353,10 +352,7 @@ def __init__(self, parent, timeout):
353352
"SSL handshake failed (see server log for more information): %s" %
354353
str(err))
355354
try:
356-
ssl.match_hostname(
357-
self._socket.getpeercert(),
358-
hostname=get_hostname_for_ssl_match(self.host)
359-
)
355+
match_hostname(self._socket.getpeercert(), hostname=self.host)
360356
except CertificateError:
361357
self._socket.close()
362358
raise

tests/test_helpers.py

+1-32
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22
from mock import Mock
3-
from rethinkdb.helpers import decode_utf8, chain_to_bytes, get_hostname_for_ssl_match
3+
from rethinkdb.helpers import decode_utf8, chain_to_bytes
44

55
@pytest.mark.unit
66
class TestDecodeUTF8Helper(object):
@@ -42,34 +42,3 @@ def test_mixed_chaining(self):
4242
result = chain_to_bytes('iron', ' ', b'man')
4343

4444
assert result == expected_string
45-
46-
47-
@pytest.mark.unit
48-
class TestSSLMatchHostHostnameHelper(object):
49-
def test_subdomain_replaced_to_star(self):
50-
expected_string = '*.example.com'
51-
52-
result = get_hostname_for_ssl_match('test.example.com')
53-
54-
assert result == expected_string
55-
56-
def test_subdomain_replaced_to_star_special_tld(self):
57-
expected_string = '*.example.co.uk'
58-
59-
result = get_hostname_for_ssl_match('test.example.co.uk')
60-
61-
assert result == expected_string
62-
63-
def test_no_subdomain_to_replace(self):
64-
expected_string = 'example.com'
65-
66-
result = get_hostname_for_ssl_match(expected_string)
67-
68-
assert result == expected_string
69-
70-
def test_no_tld(self):
71-
expected_string = 'localhost'
72-
73-
result = get_hostname_for_ssl_match(expected_string)
74-
75-
assert result == expected_string

0 commit comments

Comments
 (0)