提交 60d15b32 编写于 作者: H Hmvp

When creating a ssl connection an attribute error can be thrown

This error is not catched and stops loop_forever etc., that is very
unexpected. So we catch the error and raise a error that is actually
catched (and better represents the situation)

See also: http://bugs.python.org/issue13721

Change-Id: I495c08ec079290a97caeaf0e7f88116041d8cec6
Signed-off-by: NHmvp <hmvp@hmvp.nl>
上级 73b85d24
......@@ -2304,7 +2304,13 @@ class Client(object):
return False
def _tls_match_hostname(self):
cert = self._ssl.getpeercert()
try:
cert = self._ssl.getpeercert()
except AttributeError:
# the getpeercert can throw Attribute error: object has no attribute 'peer_certificate'
# Don't let that crash the whole client. See also: http://bugs.python.org/issue13721
raise ssl.SSLError('Not connected')
san = cert.get('subjectAltName')
if san:
have_san_dns = False
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册