diff options
author | Stanislav Laznicka <slaznick@redhat.com> | 2017-06-22 13:53:14 +0200 |
---|---|---|
committer | Pavel Vomacka <pvomacka@redhat.com> | 2017-07-27 10:28:58 +0200 |
commit | 43c74d33337d4c65947816ba31de5eaa53e001ff (patch) | |
tree | c8d0b9eb72846e1ed9e4686df96df8559f657f59 /ipalib | |
parent | b5732efda6d27f588adbc3f41259bc4511716f43 (diff) | |
download | freeipa-43c74d33337d4c65947816ba31de5eaa53e001ff.tar.gz freeipa-43c74d33337d4c65947816ba31de5eaa53e001ff.tar.xz freeipa-43c74d33337d4c65947816ba31de5eaa53e001ff.zip |
Introduce load_unknown_x509_certificate()
load_unknown_x509_certificate() serves for the cases where we
can't be sure what the format of its input certificate is. This
is the case for installers, it should not be used anywhere else.
https://pagure.io/freeipa/issue/4985
Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/x509.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ipalib/x509.py b/ipalib/x509.py index dc7a2eb3c..87f0edad4 100644 --- a/ipalib/x509.py +++ b/ipalib/x509.py @@ -421,6 +421,20 @@ def load_der_x509_certificate(data): ) +def load_unknown_x509_certificate(data): + """ + Only use this function when you can't be sure what kind of format does + your certificate have, e.g. input certificate files in installers + + :returns: a ``IPACertificate`` object. + :raises: ``ValueError`` if unable to load the certificate. + """ + try: + return load_pem_x509_certificate(data) + except ValueError: + return load_der_x509_certificate(data) + + def load_certificate_from_file(filename, dbdir=None): """ Load a certificate from a PEM file. |