Skip to content

Commit ab217b6

Browse files
committed
Last part of certificate validation: check that the hostname matches.
1 parent 372e545 commit ab217b6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tornado/simple_httpclient.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ def _on_connect(self, parsed):
182182
self._timeout = self.io_loop.add_timeout(
183183
self.start_time + self.request.request_timeout,
184184
self._on_timeout)
185+
if (self.request.validate_cert and
186+
isinstance(self.stream, SSLIOStream)):
187+
match_hostname(self.stream.socket.getpeercert(),
188+
parsed.netloc.partition(":")[0])
185189
if (self.request.method not in self._SUPPORTED_METHODS and
186190
not self.request.allow_nonstandard_methods):
187191
raise KeyError("unknown method %s" % self.request.method)

0 commit comments

Comments
 (0)