Python: Provide SSL socket with private key from PKCS#11 wrapper

邮差的信 提交于 2019-12-21 05:14:20

问题


I have a SSL server in python to which I defined the following SSLContext:

context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations(CACERTFILE)
context.load_cert_chain(CERTFILE,KEYFILE)

CERTFILE and KEYFILE contain a path to the server's certificate and private key. But you always have to provide a path to load_cert_chain().

I don't want to retrieve the private key from a file, but from a PKCS#11 wrapper like PyKCS11 or M2Crypto.

How does the context of the SSL socket has to look like, if I want to load the private key as a session object from PyKCS11 or as a PKey() object from M2Crypto. Can you give me an example?

I don't want to store the private key object from PyKCS/M2Crypto as a PEM-file or something else, because the private key should never leave the HSM.

Thank you

来源:https://stackoverflow.com/questions/38284445/python-provide-ssl-socket-with-private-key-from-pkcs11-wrapper

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!