-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Leverage External Key, such as AWS KMS #5921
Comments
At the moment, no, there's no way to sign an X.509 cert with an externally held key. I think we'd like to support this, but we don't currently. |
Maybe something like tbs_certrequest_bytes that is already available for CSR would be feasible? |
@saper You actually need to create a
This isn't hugely difficult, but it's a gross hack that requires quite a bit of domain knowledge. It would be nice to support something better. |
@reaperhulk I fully agree that this is difficult and hard to do correctly. This is something that can be done now until a better solution is available. I wouldn't recommend it either. |
If you have an OpenSSL engine wrapper around KMS — you could take a look at my POC: https://github.com/space88man/cryptography_engine cryptography has reinstated some of the low-level ENGINE APIs to make this work. |
@saper @reaperhulk @space88man I think that modification hits the need for now. |
@andrewjroth I have the exact same use case. Solved it using @space88man 's cryptography engine + https://github.com/nakedible/openssl-engine-kms Minor annoyances
It works like a charm on AWS lambda |
Good news, this is going to be very easy to do with our next release: We'll no longer be using OpenSSL's x509 layer, so anything that implements our RSA/EC/etc PrivateKey interfaces will work for signing certificates. So all you'll need to do is write an implementation of RSAPrivateKey using KMS and you'll be golden! |
@alex this is great, let's try if NSS is up to the task and could be integrated as well! |
You could definitely write a library that implements our asymmetric interfaces using NSS. I look forward to seeing what everyone produces 😄 |
I have implemented an alternate asymmetric provider to prove it's possible to myself. 😄 In this case I implemented a Once 36.0 is released we'll likely close this out and let the community build these solutions, but if you implement one please let us know and we will consider adding it to our downstream smoke tests (depending on quality of testing, popularity, etc)! Edit: The original |
For the purposes of release tracking, this task is complete now and will ship in cryptography 36.0, so I'm going to close. |
Hello,
I am trying to figure out how I can use the cryptography module to create and sign x509 certificates using a key stored in an external service, such as AWS KMS. AWS KMS has functions to send a message to the key service to be signed (ref: KMS.Client.sign from boto3). Cryptography has all the functionality to construct the x509 certificate, but it seems like it has to have access to the private key to add the CA signature. Is there any way that I can use an external process get the signature and insert it into the certificate?
I thought that I might be able to build a class based on ec.EllipticCurvePrivateKey to represent the key, and override the
sign
method to send the message to the external system to be signed. Unfortunately, it seems that the openssl backend seems to take over and require the private key to hold data. The class I wrote is here: awskms.pyI invoke x509.CertificateBuilder.sign like this:
This is the error I get:
Is there an easier way for me to do this? I am hoping to leverage the cryptography library to construct the x509 structure, but want to use an external service for the real cryptography (signing). While I am asking about AWS KMS, this could be use for any external key management system that has functionality to sign messages.
Thank you!
The text was updated successfully, but these errors were encountered: