Linux openssl命令在python中是否等效?

Linux openssl命令在python中是否等效?,linux,python-3.x,openssl,private-key,Linux,Python 3.x,Openssl,Private Key,我目前正在使用获取私钥 openssl pkcs8-in file.key-notify DER 还有一些cer文件 openssl x509-text-notify DER-in file.cer 我可以从python中处理在终端上调用命令的提取,但我更喜欢使用python库 我寻找了一些使用pyopenssl的例子,但没有找到真正类似于我试图实现的东西 如何使用python库获得相同的结果?请看一看。有并支持PKCS#8格式。因为使用python加密对我来说不起作用,所以我寻找了另一个包 我

我目前正在使用获取私钥

openssl pkcs8-in file.key-notify DER

还有一些cer文件

openssl x509-text-notify DER-in file.cer

我可以从python中处理在终端上调用命令的提取,但我更喜欢使用python库

我寻找了一些使用pyopenssl的例子,但没有找到真正类似于我试图实现的东西


如何使用python库获得相同的结果?请看一看。有并支持PKCS#8格式。

因为使用python加密对我来说不起作用,所以我寻找了另一个包

我发现使用
chilkat
正是我所需要的。它支持pkcs8,速度非常快

我的代码如下

def get_private_key(filepath, password):
    pkey = chilkat.CkPrivateKey()
    pkey.LoadPkcs8EncryptedFile(filepath, password)
    return pkey.getPkcs8Pem()


def get_certificate_and_serial(filepath):
    cert = chilkat.CkCert()
    cert.LoadFromFile(filepath)
    serial = unhexlify(cert.serialNumber())
    return cert.exportCertPem(), serial.decode('utf-8')

Chilkat可以找到

谢谢,我会查出来的