Skip to content

Commit 69d29db

Browse files
author
pjkersha
committed
Fix to SubjectAltNames support check - should only be enabled if pyasn1 is installed.
git-svn-id: http://proj.badc.rl.ac.uk/svn/ndg-security/trunk/ndg_httpsclient@8206 051b1e3e-aa0c-0410-b6c2-bfbade6052be
1 parent ee7d8ca commit 69d29db

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ndg/httpsclient/ssl_peer_verification.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,16 @@
1313
try:
1414
from ndg.httpsclient.subj_alt_name import SubjectAltName
1515
from pyasn1.codec.der import decoder as der_decoder
16-
subj_alt_name_support = True
16+
SUBJ_ALT_NAME_SUPPORT = True
1717
except ImportError, e:
18-
subj_alt_name_support = False
18+
SUBJ_ALT_NAME_SUPPORT = False
19+
SUBJ_ALT_NAME_SUPPORT_MSG = (
20+
'SubjectAltName support is disabled - check pyasn1 package '
21+
'installation to enable'
22+
)
23+
import warnings
24+
warnings.warn(SUBJ_ALT_NAME_SUPPORT_MSG)
25+
1926

2027
class ServerSSLCertVerification(object):
2128
"""Check server identity. If hostname doesn't match, allow match of
@@ -64,12 +71,12 @@ def __init__(self, certDN=None, hostname=None, subj_alt_name_match=True):
6471
self.hostname = hostname
6572

6673
if subj_alt_name_match:
67-
if not subj_alt_name_support:
74+
if not SUBJ_ALT_NAME_SUPPORT:
6875
log.warning('Overriding "subj_alt_name_match" keyword setting: '
6976
'peer verification with subjectAltNames is disabled')
7077
self.__subj_alt_name_match = False
71-
72-
self.__subj_alt_name_match = True
78+
else:
79+
self.__subj_alt_name_match = True
7380
else:
7481
log.debug('Disabling peer verification with subject '
7582
'subjectAltNames!')

0 commit comments

Comments
 (0)