models.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:mist.api 作者: mistio 项目源码 文件源码
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.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号