(cherry picked from commit b29f238083
)
Co-authored-by: Songmin Li <lisongmin@protonmail.com>
pull/488/head
parent
651f2b8f5d
commit
563e3a2791
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- "openssl_csr - the module no longer crashes with 'permitted_subtrees/excluded_subtrees must be a non-empty list or None' if only one of ``name_constraints_permitted`` and ``name_constraints_excluded`` is provided (https://github.com/ansible-collections/community.crypto/issues/481)."
|
|
@ -528,8 +528,8 @@ class CertificateSigningRequestCryptographyBackend(CertificateSigningRequestBack
|
||||||
if self.name_constraints_permitted or self.name_constraints_excluded:
|
if self.name_constraints_permitted or self.name_constraints_excluded:
|
||||||
try:
|
try:
|
||||||
csr = csr.add_extension(cryptography.x509.NameConstraints(
|
csr = csr.add_extension(cryptography.x509.NameConstraints(
|
||||||
[cryptography_get_name(name, 'name constraints permitted') for name in self.name_constraints_permitted],
|
[cryptography_get_name(name, 'name constraints permitted') for name in self.name_constraints_permitted] or None,
|
||||||
[cryptography_get_name(name, 'name constraints excluded') for name in self.name_constraints_excluded],
|
[cryptography_get_name(name, 'name constraints excluded') for name in self.name_constraints_excluded] or None,
|
||||||
), critical=self.name_constraints_critical)
|
), critical=self.name_constraints_critical)
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
raise OpenSSLObjectError('Error while parsing name constraint: {0}'.format(e))
|
raise OpenSSLObjectError('Error while parsing name constraint: {0}'.format(e))
|
||||||
|
@ -678,8 +678,8 @@ class CertificateSigningRequestCryptographyBackend(CertificateSigningRequestBack
|
||||||
|
|
||||||
def _check_nameConstraints(extensions):
|
def _check_nameConstraints(extensions):
|
||||||
current_nc_ext = _find_extension(extensions, cryptography.x509.NameConstraints)
|
current_nc_ext = _find_extension(extensions, cryptography.x509.NameConstraints)
|
||||||
current_nc_perm = [to_text(altname) for altname in current_nc_ext.value.permitted_subtrees] if current_nc_ext else []
|
current_nc_perm = [to_text(altname) for altname in current_nc_ext.value.permitted_subtrees or []] if current_nc_ext else []
|
||||||
current_nc_excl = [to_text(altname) for altname in current_nc_ext.value.excluded_subtrees] if current_nc_ext else []
|
current_nc_excl = [to_text(altname) for altname in current_nc_ext.value.excluded_subtrees or []] if current_nc_ext else []
|
||||||
nc_perm = [to_text(cryptography_get_name(altname, 'name constraints permitted')) for altname in self.name_constraints_permitted]
|
nc_perm = [to_text(cryptography_get_name(altname, 'name constraints permitted')) for altname in self.name_constraints_permitted]
|
||||||
nc_excl = [to_text(cryptography_get_name(altname, 'name constraints excluded')) for altname in self.name_constraints_excluded]
|
nc_excl = [to_text(cryptography_get_name(altname, 'name constraints excluded')) for altname in self.name_constraints_excluded]
|
||||||
if set(nc_perm) != set(current_nc_perm) or set(nc_excl) != set(current_nc_excl):
|
if set(nc_perm) != set(current_nc_perm) or set(nc_excl) != set(current_nc_excl):
|
||||||
|
|
Loading…
Reference in New Issue