- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在 python 中使用以下代码和 pyOpenSSL 创建了一个 key 对:
from OpenSSL import crypto
k = crypto.PKey()
k.generate_key(crypto.TYPE_RSA, 2048)
最佳答案
我知道这是一个老问题 - 但正如我刚刚发现的那样,我想我应该添加一个答案。
使用 Python 3.x 执行此操作的最简单方法是使用 PyCryptodome .
Python 中的(对于 2048 位 key ):
from Cryptodome.PublicKey import RSA
key = RSA.generate(2048)
pv_key_string = key.exportKey()
with open ("private.pem", "w") as prv_file:
print("{}".format(pv_key_string.decode()), file=prv_file)
pb_key_string = key.publickey().exportKey()
with open ("public.pem", "w") as pub_file:
print("{}".format(pb_key_string.decode()), file=pub_file)
如果您想在 (Linux) 命令行上检查私钥,请使用:
$ openssl rsa -check -inform pem -noout -in private.pem
RSA key ok
...
关于python - pyOpenSSL 创建一个 pem 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19651587/
我正在使用 Titanium 3.0 并尝试更新 pyOpenSSL。我检查了 python 网站,只看到 Windows 的可下载链接。在 Tianium 论坛中,他们说“如果您使用 MacPort
我想使用pyopenssl验证下载文件的签名和证书,但文档不明确,谷歌也无济于事。 我在用户的机器上有一个根 CA 证书,现在当用户下载文件时,我会连同它一起发送一个证书和签名。首先我需要在机器上使用
在 Apache 中,我成功地使用了以下 OpenSSL 密码设置: SSLHonorCipherOrder on SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+a
在回答this question , 我在看 the docs for PyOpenSSL - OpenSSL 的 python 包装器。 它有签名和证书的东西,但是所有的加密东西在哪里?我是否遗漏了
我有以下代码 key = OpenSSL.crypto.PKey() key.generate_key(OpenSSL.crypto.TYPE_RSA, 1024) cert = OpenSSL.cr
我在 Macbook Pro 上双启动了一个 Windows 10 分区:Mac:El Capitan(64 位)Windows:Windows 10 64 位,使用 fat 文件系统格式化 在 Wi
我有一个套接字服务器,我正试图将其转移到 python 2.5 上的 SSL,但我遇到了 pyOpenSSL 的障碍。我找不到任何关于使用它的好教程,所以我主要靠猜测。 这是我的服务器如何设置套接字:
我正在使用 pyOpenSSL 大量生成 CSR。 我需要生成一个受密码保护的私钥文件。 代码片段: key = crypto.PKey() key.generate_key(type, bits)
我需要在 python 中对打开的连接执行重新协商。似乎the renegotiate function is not implemented .有什么方法可以启动重新协商? 我尝试使用 set_co
更新:do_handshake 似乎正在重置密码列表 诚然,这是一个非常具体的场景,但也许有人会有想法。我试图强制服务器仅接受 RC4-SHA(仅出于调试原因)。我的代码看起来像这样: ctx
我可以获得私钥(PEM格式),但我不知道如何生成公钥: from OpenSSL import crypto, SSL key = crypto.PKey() key.generate_key(cry
我需要创建 SSL signatures对于大 *.tar.gz使用 Python 3 的文件(千兆字节的数据)和 pyopenssl模块。 下面是我的代码(有效)的简化摘录。有问题的行是以下一行:
我生成自签名证书 CA_KEY_FILE = os.path.join(settings.ROOT_CRT_PATH, 'rootCA.key') CA_CERT_FILE = os.path.joi
我目前正在尝试编写一个 python 服务器脚本,该脚本应根据其公钥对当前客户端进行身份验证。由于我使用的是扭曲的,example in the twisted documenteation让我开始了
我正在尝试创建 python 脚本,它将采用 PKCS#12 包并打印 x509 证书中包含的一些信息并用于此目的 PyOpenSSL 模块。到目前为止,我想从证书公钥中获取。但是 PKey 对象没有
我有两个证书,一个用于签署 client.crt 的 root.crt。 我想验证 client.crt 确实是由 root.key 签名的。 在终端上使用 openssl,它是这样工作的: $ op
我相信自从这个 question , pyOpenSSL 已经开始支持签名验证(自 pyOpenSSL 0.11 开始。 我正在做一个由其他人使用 M2Crypto 启动的项目. M2Crypto 包
我正在编写一个需要在客户端浏览器中安装证书的应用程序。我在“上下文”对象的 PyOpenSSL 文档中找到了这个,但我看不到任何关于回调应该如何验证证书的信息,只是它应该以某种方式验证。 set
我试图在 Digital Ocean Ubuntu 16.04 服务器中安装 pyopenssl 模块。我收到此错误“密码学构建轮失败”,随后出现一些错误。 Collecting pyopenssl
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 8 年前。 Improve th
我是一名优秀的程序员,十分优秀!