Enforce that PEM strings (certs, keys, CSR) are internally passed as str, not bytes

This was already true in most places but not 100%, leading to lots of redundant checks and conversions.
This commit is contained in:
Marti Raudsepp
2018-12-26 19:49:56 +02:00
parent c60b712523
commit e24a94d798
8 changed files with 27 additions and 61 deletions

View File

@ -44,14 +44,9 @@ def create_pkcs12(cert, chain, p12_tmp, key, alias, passphrase):
:param alias:
:param passphrase:
"""
if isinstance(cert, bytes):
cert = cert.decode('utf-8')
if isinstance(chain, bytes):
chain = chain.decode('utf-8')
if isinstance(key, bytes):
key = key.decode('utf-8')
assert isinstance(cert, str)
assert isinstance(chain, str)
assert isinstance(key, str)
with mktempfile() as key_tmp:
with open(key_tmp, 'w') as f: