Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does iot-sdk-python support PKCS#11? #1093

Closed
devcopilot opened this issue Jan 16, 2023 · 3 comments
Closed

Does iot-sdk-python support PKCS#11? #1093

devcopilot opened this issue Jan 16, 2023 · 3 comments

Comments

@devcopilot
Copy link

PKCS#11 is supported in azure-iot-sdk-c. I read the documentation and sample codes of iot-sdk-python but did not find information about PKCS#11 support.

Does azure-iot-sdk-python support PKCS#11 to use the private keys stored in a HSM(not TPM) ?

Thanks for answering my question :)

@BertKleewein
Copy link
Member

The short answer is "no". The longer answer is "you can do anything in Python if you're ready to hack enough." :)

azure-iot-sdk-python uses standard Python TLS stack which uses a library called OpenSSL. This library does not support PKCS #11. There is a proposal to add this, but it has gone stale.

https://discuss.python.org/t/allow-ssl-client-certificate-private-key-verification-to-be-delegated-to-a-hsm/6942

I don't know if pyOpenSSL supports PKCS #11, but it may be possible to use pyOpenSSL with azure-iot-sdk-python. This would only work if pyOpenSSL can create an SSLContext object. We would also have to add an API to manually set the SSLContext on a azure-iot-sdk-python client object.

Depending on your HSM, another option might be to use python-mbedtls. This would also need an API to manually set the SSLContext. I did some playing around with this a few years ago -- enough to do a POC, -- but it was ugly and the project changed direction before I could finish it.

@devcopilot
Copy link
Author

Thanks a lot for the suggestions :) It is good enough for me to know currently it is not supported.

I see azure-sdk-c supports pkcs11. I will use that library.

@IniterWorker
Copy link
Contributor

Hi @BertKleewein,

Apologies for the direct ping, but I was wondering if you could share the "enough to do a POC" details. This would be incredibly helpful for us to potentially finalize the work you've started.

Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants