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(convert_pem_str_to_cert): always return the first cert #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions acertmgr/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,14 @@ def convert_cert_to_pem_str(cert):


# @brief load a PEM certificate from str
# @return a certificate object or a list of objects if multiple are in the string
# @return a certificate object or the first certificate if multiple are in the string
def convert_pem_str_to_cert(certdata):
certs = re.findall(r'(-----BEGIN CERTIFICATE-----\n[^\-]+\n-----END CERTIFICATE-----)',
certdata, re.DOTALL)
result = list()
for data in certs:
result.append(x509.load_pem_x509_certificate(data.encode('utf8'), default_backend()))
return result[0] if len(result) == 1 else result
return result[0]


# @brief serialize cert/csr to DER bytes
Expand Down