Skip to content

Commit

Permalink
Last part of certificate validation: check that the hostname matches.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Feb 15, 2011
1 parent 372e545 commit ab217b6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tornado/simple_httpclient.py
Expand Up @@ -182,6 +182,10 @@ def _on_connect(self, parsed):
self._timeout = self.io_loop.add_timeout(
self.start_time + self.request.request_timeout,
self._on_timeout)
if (self.request.validate_cert and
isinstance(self.stream, SSLIOStream)):
match_hostname(self.stream.socket.getpeercert(),
parsed.netloc.partition(":")[0])
if (self.request.method not in self._SUPPORTED_METHODS and
not self.request.allow_nonstandard_methods):
raise KeyError("unknown method %s" % self.request.method)
Expand Down

0 comments on commit ab217b6

Please sign in to comment.