openssl_*: Allow user to specify privatekey passphrase

Allow a user to specify the privatekey passphrase when dealing with
openssl modules.
This commit is contained in:
Yanis Guenane 2017-07-19 12:02:29 +02:00 committed by Toshio Kuratomi
parent a260063ffd
commit f40db199aa
4 changed files with 66 additions and 12 deletions

View file

@ -26,12 +26,14 @@ except ImportError:
import hashlib
def get_fingerprint(path):
def get_fingerprint(path, passphrase):
"""Generate the fingerprint of the public key. """
fingerprint = {}
privatekey = crypto.load_privatekey(crypto.FILETYPE_PEM, open(path, 'r').read())
privatekey = crypto.load_privatekey(crypto.FILETYPE_PEM,
open(path, 'rb').read(),
passphrase)
try:
publickey = crypto.dump_publickey(crypto.FILETYPE_ASN1, privatekey)