abhishek-ram/django-pyas2

Why private key password is required?

rsoltys opened this issue · 4 comments

I've tried to add private key without password and I got 500:

File "/src/django-pyas2/pyas2/forms.py", line 98, in clean
    cleaned_data["key_file"], cleaned_data["key_pass"]

Exception Type: KeyError at /en/admin/pyas2/privatekey/add/
Exception Value: 'key_pass'

Could the key_pass be optional?

Thanks!

It is not optional, I guess I need to raise validation error here.

@abhishek-ram thanks for reply. I have no private key password in my use case. Could you please explain to me, why the key_pass has to be required?

For security reasons a password needs to be set for a private key. You should be able to add it like so https://security.stackexchange.com/questions/59136/can-i-add-a-password-to-an-existing-private-key

For anyone that has a private key without a password and wants to import it, you can conver the key+kert to a p12 file, set a password and import it :)

openssl pkcs12 -export -in certificate.pem -inkey private.key -out pyas2-friendly.p12 -name "To import cert"
``