certificate.py 文件源码

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

项目:lecm 作者: Spredzy 项目源码 文件源码
def _create_account_key(self):
        account_key = crypto.PKey()

        if self.type == 'RSA':
            crypto_type = crypto.TYPE_RSA
        else:
            crypto_type = crypto.TYPE_DSA

        try:
            LOG.info('[global] Generating account key: %s \
                     (type: %s, size: %s)' %
                     (self.account_key_name, self.type, self.size))
            account_key.generate_key(crypto_type, self.size)
        except (TypeError, ValueError):
            raise

        try:
            LOG.debug('[global] Writting account key: %s/private/%s' %
                      (self.path, self.account_key_name))
            accountkey_file = os.open('%s/private/%s' %
                                      (self.path, self.account_key_name),
                                      os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
                                      0o600)
            os.write(accountkey_file,
                     crypto.dump_privatekey(crypto.FILETYPE_PEM, account_key))
            os.close(accountkey_file)
        except IOError:
            try:
                os.remove('%s/private/%s.key' %
                          (self.path, self.account_key_name))
            except OSError:
                pass
            raise
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号