Fix import certificate private key encoding (#434)
When importing a certificate, the private key is passed to the import/upload process from the UI as a str object. In Python3 this raises two issues when processing the private key - the private key validation fails and database insert of the certificate fails. The fix in both cases is to correctly encode the private key as a bytes object.
This commit is contained in:
committed by
kevgliss
parent
6cac2838e3
commit
3ad7a37f95
@ -364,6 +364,13 @@ def test_upload(logged_in_user):
|
||||
assert 'ACustomName' in cert.name
|
||||
|
||||
|
||||
# verify upload with a private key as a str
|
||||
def test_upload_private_key_str(logged_in_user):
|
||||
from lemur.certificates.service import upload
|
||||
cert = upload(body=INTERNAL_VALID_LONG_STR, chain=INTERNAL_VALID_SAN_STR, private_key=PRIVATE_KEY_STR.decode('utf-8'), owner='joe@example.com', name='ACustomName')
|
||||
assert cert
|
||||
|
||||
|
||||
@pytest.mark.parametrize("token,status", [
|
||||
(VALID_USER_HEADER_TOKEN, 200),
|
||||
(VALID_ADMIN_HEADER_TOKEN, 200),
|
||||
|
Reference in New Issue
Block a user