Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix certificate type error when exporting to file #2327

Closed
wants to merge 1 commit into from
Closed

Fix certificate type error when exporting to file #2327

wants to merge 1 commit into from

Conversation

netoarmando
Copy link
Member

Commands ipa ca-show and ipa cert-show share the same code, this commit updates the former, closing the gap between them.

Reflecting the changes done in 5a44ca6.

https://pagure.io/freeipa/issue/7628

Signed-off-by: Armando Neto abiagion@redhat.com

To be more specific, ipa cert-show code is:

def forward(self, *args, **options):
if 'certificate_out' in options:
certificate_out = options.pop('certificate_out')
try:
util.check_writable_file(certificate_out)
except errors.FileError as e:
raise errors.ValidationError(name='certificate-out',
error=str(e))
else:
certificate_out = None
result = super(CertRetrieveOverride, self).forward(*args, **options)
if certificate_out is not None:
if options.get('chain', False):
certs = result['result']['certificate_chain']
else:
certs = [result['result']['certificate']]
certs = (x509.load_der_x509_certificate(base64.b64decode(cert))
for cert in certs)
x509.write_certificate_list(certs, certificate_out)
return result

@netoarmando netoarmando added ipa-4-7 needs review Pull Request is waiting for a review labels Sep 4, 2018
Commands `ipa ca-show` and `ipa cert-show` share the same code,
this commit updates the former, closing the gap between them.

Reflecting the changes done in 5a44ca6.

https://pagure.io/freeipa/issue/7628

Signed-off-by: Armando Neto <abiagion@redhat.com>
result['result']['certificate'])
]
certs = [result['result']['certificate']]
certs = (x509.load_der_x509_certificate(base64.b64decode(cert))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tricky! This approach is a bit of a hack. In Python 3, base64.b64decode() accepts both ASCII text and ASCII bytes, and returns bytes. It works for me.

@tiran tiran added ack Pull Request approved, can be merged pushed Pull Request has already been pushed and removed needs review Pull Request is waiting for a review labels Sep 6, 2018
@tiran
Copy link
Member

tiran commented Sep 6, 2018

master:

  • c706449 Fix certificate type error when exporting to file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ack Pull Request approved, can be merged pushed Pull Request has already been pushed
Projects
None yet
2 participants