Use ssl.match_hostname from urllib3 as it was removed from Python 3.12
Based on upstream freeipa rawhide patch by Miro Hrončok See https://github.com/python/cpython/pull/94224#issuecomment-1621097418 Fixes: https://pagure.io/freeipa/issue/9409 Signed-off-by: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Fraser Tweedale <ftweedal@redhat.com> Reviewed-By: Miro Hroncok <miro@hroncok.cz> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
1 parent
00c0a62a6a
commit
d2ed490ff4
5 files changed
+18
-9
No files matched your search
+8
-2
@@ -565,11 +565,11 @@ Requires: python3-pyasn1 >= 0.3.2-2
|
|||||||
Requires: python3-sssdconfig >= %{sssd_version}
|
Requires: python3-sssdconfig >= %{sssd_version}
|
||||||
Requires: python3-psutil
|
Requires: python3-psutil
|
||||||
Requires: rpm-libs
|
Requires: rpm-libs
|
||||||
# Indirect dependency: use newer urllib3 with TLS 1.3 PHA support
|
|
||||||
%if 0%{?rhel}
|
%if 0%{?rhel}
|
||||||
Requires: python3-urllib3 >= 1.24.2-3
|
Requires: python3-urllib3 >= 1.24.2-3
|
||||||
%else
|
%else
|
||||||
Requires: python3-urllib3 >= 1.25.7
|
# For urllib3.util.ssl_match_hostname
|
||||||
|
Requires: python3-urllib3 >= 1.25.8
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%description -n python3-ipaserver
|
%description -n python3-ipaserver
|
||||||
@@ -896,6 +896,12 @@ Requires: platform-python-setuptools
|
|||||||
%else
|
%else
|
||||||
Requires: python3-setuptools
|
Requires: python3-setuptools
|
||||||
%endif
|
%endif
|
||||||
|
%if 0%{?rhel}
|
||||||
|
Requires: python3-urllib3 >= 1.24.2-3
|
||||||
|
%else
|
||||||
|
# For urllib3.util.ssl_match_hostname
|
||||||
|
Requires: python3-urllib3 >= 1.25.8
|
||||||
|
%endif
|
||||||
|
|
||||||
%description -n python3-ipalib
|
%description -n python3-ipalib
|
||||||
IPA is an integrated solution to provide centrally managed Identity (users,
|
IPA is an integrated solution to provide centrally managed Identity (users,
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ if __name__ == '__main__':
|
|||||||
"pyasn1",
|
"pyasn1",
|
||||||
"pyasn1-modules",
|
"pyasn1-modules",
|
||||||
"six",
|
"six",
|
||||||
|
"urllib3",
|
||||||
],
|
],
|
||||||
extras_require={
|
extras_require={
|
||||||
"install": ["dbus-python"], # for certmonger and resolve1
|
"install": ["dbus-python"], # for certmonger and resolve1
|
||||||
|
|||||||
+7
-3
@@ -36,7 +36,6 @@ import binascii
|
|||||||
import datetime
|
import datetime
|
||||||
import enum
|
import enum
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import ssl
|
|
||||||
import base64
|
import base64
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@@ -53,6 +52,11 @@ from pyasn1.codec.der import decoder, encoder
|
|||||||
from pyasn1_modules import rfc2315, rfc2459
|
from pyasn1_modules import rfc2315, rfc2459
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
try:
|
||||||
|
from urllib3.util import ssl_match_hostname
|
||||||
|
except ImportError:
|
||||||
|
from urllib3.packages import ssl_match_hostname
|
||||||
|
|
||||||
from ipalib import errors
|
from ipalib import errors
|
||||||
from ipapython.dnsutil import DNSName
|
from ipapython.dnsutil import DNSName
|
||||||
|
|
||||||
@@ -385,6 +389,7 @@ class IPACertificate(crypto_x509.Certificate):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def match_hostname(self, hostname):
|
def match_hostname(self, hostname):
|
||||||
|
# The caller is expected to catch any exceptions
|
||||||
match_cert = {}
|
match_cert = {}
|
||||||
|
|
||||||
match_cert['subject'] = match_subject = []
|
match_cert['subject'] = match_subject = []
|
||||||
@@ -401,8 +406,7 @@ class IPACertificate(crypto_x509.Certificate):
|
|||||||
for value in values:
|
for value in values:
|
||||||
match_san.append(('DNS', value))
|
match_san.append(('DNS', value))
|
||||||
|
|
||||||
# deprecated in Python3.7 without replacement
|
ssl_match_hostname.match_hostname(
|
||||||
ssl.match_hostname( # pylint: disable=deprecated-method
|
|
||||||
match_cert, DNSName(hostname).ToASCII()
|
match_cert, DNSName(hostname).ToASCII()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import dbus
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import ssl
|
|
||||||
import sys
|
import sys
|
||||||
import syslog
|
import syslog
|
||||||
import time
|
import time
|
||||||
@@ -2378,7 +2377,7 @@ def check_ipa_ca_san(cert):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
cert.match_hostname(expect)
|
cert.match_hostname(expect)
|
||||||
except ssl.CertificateError:
|
except x509.ssl_match_hostname.CertificateError:
|
||||||
raise errors.ValidationError(
|
raise errors.ValidationError(
|
||||||
name='certificate',
|
name='certificate',
|
||||||
error='Does not have a \'{}\' SAN'.format(expect)
|
error='Does not have a \'{}\' SAN'.format(expect)
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import os
|
|||||||
import glob
|
import glob
|
||||||
import shutil
|
import shutil
|
||||||
import fileinput
|
import fileinput
|
||||||
import ssl
|
|
||||||
import stat
|
import stat
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
@@ -717,7 +716,7 @@ def http_certificate_ensure_ipa_ca_dnsname(http):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
cert.match_hostname(expect)
|
cert.match_hostname(expect)
|
||||||
except ssl.CertificateError:
|
except x509.ssl_match_hostname.CertificateError:
|
||||||
if certs.is_ipa_issued_cert(api, cert):
|
if certs.is_ipa_issued_cert(api, cert):
|
||||||
request_id = certmonger.get_request_id(
|
request_id = certmonger.get_request_id(
|
||||||
{'cert-file': paths.HTTPD_CERT_FILE})
|
{'cert-file': paths.HTTPD_CERT_FILE})
|
||||||
|
|||||||
Reference in new issue
Block a user