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:
Charles Hendrie
2016-10-08 19:04:54 -05:00
committed by kevgliss
parent 6cac2838e3
commit 3ad7a37f95
4 changed files with 47 additions and 2 deletions

View File

@ -189,6 +189,11 @@ def upload(**kwargs):
else:
kwargs['roles'] = roles
if kwargs.get('private_key'):
private_key = kwargs['private_key']
if not isinstance(private_key, bytes):
kwargs['private_key'] = private_key.encode('utf-8')
cert = Certificate(**kwargs)
cert = database.create(cert)