openssl_certificate: Ensure issuer field is set (#34982)

Ensure the Issuer field of the certificate is set when using the
selfsigned backend.

Fixes: https://github.com/ansible/ansible/issues/34963
pull/35052/head
Yanis Guenane 7 years ago committed by John R Barker
parent cf88bfdbbf
commit a2b00e9b52

@ -449,6 +449,7 @@ class SelfSignedCertificate(Certificate):
# 10 years. 315360000 is 10 years in seconds. # 10 years. 315360000 is 10 years in seconds.
cert.gmtime_adj_notAfter(315360000) cert.gmtime_adj_notAfter(315360000)
cert.set_subject(self.csr.get_subject()) cert.set_subject(self.csr.get_subject())
cert.set_issuer(self.csr.get_subject())
cert.set_version(self.version - 1) cert.set_version(self.version - 1)
cert.set_pubkey(self.csr.get_pubkey()) cert.set_pubkey(self.csr.get_pubkey())
cert.add_extensions(self.csr.get_extensions()) cert.add_extensions(self.csr.get_extensions())

@ -6,6 +6,11 @@
shell: 'openssl x509 -noout -modulus -in {{ output_dir }}/cert.pem' shell: 'openssl x509 -noout -modulus -in {{ output_dir }}/cert.pem'
register: cert_modulus register: cert_modulus
- name: Validate certificate (test - issuer value)
shell: 'openssl x509 -noout -in {{ output_dir}}/cert.pem -text | grep "Issuer" | sed "s/.*: \(.*\)/\1/g"'
register: cert_issuer
- name: Validate certificate (test - certficate version == default == 3) - name: Validate certificate (test - certficate version == default == 3)
shell: 'openssl x509 -noout -in {{ output_dir}}/cert.pem -text | grep "Version" | sed "s/.*: \(.*\) .*/\1/g"' shell: 'openssl x509 -noout -in {{ output_dir}}/cert.pem -text | grep "Version" | sed "s/.*: \(.*\) .*/\1/g"'
register: cert_version register: cert_version
@ -15,6 +20,7 @@
that: that:
- cert_modulus.stdout == privatekey_modulus.stdout - cert_modulus.stdout == privatekey_modulus.stdout
- cert_version.stdout == '3' - cert_version.stdout == '3'
- cert_issuer.stdout == 'CN=www.example.com'
- name: Validate certificate idempotence - name: Validate certificate idempotence
assert: assert:

Loading…
Cancel
Save