def clean(self):
"""Ensures that self is a valid RSA keypair."""
from Crypto import Random
Random.atfork()
if 'RSA' not in self.private:
raise me.ValidationError("Private key is not a valid RSA key.")
# Generate public key from private key file.
try:
key = RSA.importKey(self.private)
self.public = key.publickey().exportKey('OpenSSH')
except Exception:
log.exception("Error while constructing public key "
"from private.")
raise me.ValidationError("Private key is not a valid RSA key.")
评论列表
文章目录