File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3636import datetime
3737import enum
3838import ipaddress
39- import ssl
4039import base64
4140import re
4241
5352from pyasn1_modules import rfc2315 , rfc2459
5453import six
5554
55+ try :
56+ from urllib3 .util import ssl_match_hostname
57+ except ImportError :
58+ from urllib3 .packages import ssl_match_hostname
59+
5660from ipalib import errors
5761from ipapython .dnsutil import DNSName
5862
@@ -385,6 +389,7 @@ def san_a_label_dns_names(self):
385389 return result
386390
387391 def match_hostname (self , hostname ):
392+ # The caller is expected to catch any exceptions
388393 match_cert = {}
389394
390395 match_cert ['subject' ] = match_subject = []
@@ -401,8 +406,7 @@ def match_hostname(self, hostname):
401406 for value in values :
402407 match_san .append (('DNS' , value ))
403408
404- # deprecated in Python3.7 without replacement
405- ssl .match_hostname ( # pylint: disable=deprecated-method
409+ ssl_match_hostname .match_hostname (
406410 match_cert , DNSName (hostname ).ToASCII ()
407411 )
408412
Original file line number Diff line number Diff line change 3030import os
3131import re
3232import shutil
33- import ssl
3433import sys
3534import syslog
3635import time
@@ -2378,7 +2377,7 @@ def check_ipa_ca_san(cert):
23782377
23792378 try :
23802379 cert .match_hostname (expect )
2381- except ssl .CertificateError :
2380+ except x509 . ssl_match_hostname .CertificateError :
23822381 raise errors .ValidationError (
23832382 name = 'certificate' ,
23842383 error = 'Does not have a \' {}\' SAN' .format (expect )
Original file line number Diff line number Diff line change 1212import glob
1313import shutil
1414import fileinput
15- import ssl
1615import stat
1716import sys
1817import tempfile
@@ -717,7 +716,7 @@ def http_certificate_ensure_ipa_ca_dnsname(http):
717716
718717 try :
719718 cert .match_hostname (expect )
720- except ssl .CertificateError :
719+ except x509 . ssl_match_hostname .CertificateError :
721720 if certs .is_ipa_issued_cert (api , cert ):
722721 request_id = certmonger .get_request_id (
723722 {'cert-file' : paths .HTTPD_CERT_FILE })
You can’t perform that action at this time.
0 commit comments