You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As currently structured this project has dependencies on both PyCrypto and M2Crypto. This doesn't seem ideal, especially as the latter is essentially a moribund project with no active path towards py3 compatibility. Is there a plan to move to just one?
Full disclosure: This came to my attention because I work on pyca/cryptography, which is the underlying dependency for pyOpenSSL and the future of PyCrypto. pyca/cryptography itself currently would not fit your needs as our X509 support is incomplete (as is our serialization of asymmetric keys), but we're working on it.
Yes, our plan would be to hopefully migrate to a single cryptography library. My initial (very quick) research on the matter didn't reveal any that met all of the needs of the project, but I was hoping to revisit this issue when we were a bit closer to launch and see how we can consolidate.
If I remember correctly, it was mainly the handling of X.509, SANs and CSRs that caused the problems. (and I didn't find any Python libraries capable of reading SANs within CSRs)
That being said, I should probably pay a bit more attention to the exact library I am using to help ease that transition. :)
I am sure you have more knowledge about this domain than I do and I would be very thankful for any suggestions or pull requests to help resolve this issue.
I apologize in advance for the length of this comment...
The current choices in python cryptography are as follows (in order of current download popularity):
PyCrypto
pyOpenSSL
cryptography
M2Crypto
Based on my understanding of the current codebase it appears none of them quite meet your needs. Ultimately you need a library that can do the following:
RSA PKCS1v1.5 SHA256 for JSON web signatures. (Presumably this is the RSA key pair that is associated with the "account" and therefore independent from the key used for the certificate request. Why use PKCS1v1.5? Why not PSS? It's an optional choice in the draft.)
Generate a CSR with subject DN and subjectAltName extensions
Verify CSR signature against private key
Generate a private key (RSA required, EC nice)
Self-sign a certificate
Parse a certificate (including parsing of subject/issuer DN and SAN extension)
If there's anything I've missed let me know!
So how do the libraries stack up?
PyCrypto
Does not support:
X509 parsing or generation.
elliptic curves
pyOpenSSL
Does not support:
SAN parsing or generation in CSRs.
cryptography
Does not support:
DER import of keys (coming next release)
Parsing of subject/issuer DN (coming next release) or SAN extension in X509 certificates
Parsing or generation of CSRs
Verifying CSRs (although that's an easy one after we support parsing)
Self-signing X509 certificates (or generation of any kind)
M2Crypto
Supports everything you need right now, but with the following disadvantages:
No Python 3 support
Has a tendency to output things to stdout (see: key generation)
Difficult to compile for many (swig dependency)
Project is essentially maintenance only.
So in the short term you should stay with what you've got. Longer term I see two viable options:
Add SAN CSR support into pyOpenSSL and switch exclusively to that (with an implicit dependency on cryptography so you could migrate to pure cryptography in the future).
Wait for cryptography itself to support everything required and switch directly to that. This will take longer since we have more gaps at the moment and is therefore probably not a viable choice for launch.
@reaperhulk Thanks so much for this research and write-up! I am definitely not keen on sticking with M2Crypto as we move forward. We have already experienced some of the compiling issues like #152 and I am aware of the fractured development.
Both of your longer-term solutions seem reasonable, and I think it depends a bit on how the next few months pan out (although it seems like you might have the ability to make the switch easier :))
With regards to... "Why use PKCS1v1.5? Why not PSS?"
I agree that we should us PSS. I think this largely came down to a time crunch as the existing dummy server only supported the following signature types.
As we were rushing to complete the client demo, it was easier to use one of the supported types rather than modifying the server implementation. (The server code throws an error if you currently try to use it)
Hopefully we will transition over to the Boulder (previously called Anvil) ACME server which should be a bit more complete and the client will switch over to PSS. Thanks for the heads up though! I will add a TODO in the code.
@reaperhulk Correct me if I am wrong but one option for parsing and verifying CSRs as well as self-signing X509 certs using cryptography can be to drop down to the bindings layer and use the OpenSSL API directly.
The M2crypto API isn't much more than a thin wrapper around OpenSSL anyway so using the bindings layer wouldn't be that ugly.
I just skimmed through all the crypto-library-using-code in letsencrypt. In terms of getting to "just one crypto" library here's my analysis:
There's a bunch of X509 stuff missing before we can use just pyca/cryptography, and remove M2Crypto. I filed Feature needed for letsencrypt to use us instead of M2Crypto pyca/cryptography#1957 upstream to track this, if you think I'm missing everything from that issue, let me know :-) (I'm going to try to prioritize this stuff for our next release)
All the things currently use PyCrypto are supported by pyca/cryptography. Since letsnecrypt uses PyOpenSSL, it's already pulling in pyca/cryptography. If I did that migration (s/pycrypto/cryptography/ :-), would that patch be of interest?
PyOpenSSL is currently being used for some SSL stuff that I didn't look at too closely :-)
—
Reply to this email directly or view it on GitHub #164 (comment)
.
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084
Activity
jdkasten commentedon Jan 16, 2015
Yes, our plan would be to hopefully migrate to a single cryptography library. My initial (very quick) research on the matter didn't reveal any that met all of the needs of the project, but I was hoping to revisit this issue when we were a bit closer to launch and see how we can consolidate.
If I remember correctly, it was mainly the handling of X.509, SANs and CSRs that caused the problems. (and I didn't find any Python libraries capable of reading SANs within CSRs)
That being said, I should probably pay a bit more attention to the exact library I am using to help ease that transition. :)
I am sure you have more knowledge about this domain than I do and I would be very thankful for any suggestions or pull requests to help resolve this issue.
Best,
James
reaperhulk commentedon Jan 17, 2015
I apologize in advance for the length of this comment...
The current choices in python cryptography are as follows (in order of current download popularity):
Based on my understanding of the current codebase it appears none of them quite meet your needs. Ultimately you need a library that can do the following:
If there's anything I've missed let me know!
So how do the libraries stack up?
PyCrypto
Does not support:
pyOpenSSL
Does not support:
cryptography
Does not support:
M2Crypto
Supports everything you need right now, but with the following disadvantages:
So in the short term you should stay with what you've got. Longer term I see two viable options:
jdkasten commentedon Jan 18, 2015
@reaperhulk Thanks so much for this research and write-up! I am definitely not keen on sticking with M2Crypto as we move forward. We have already experienced some of the compiling issues like #152 and I am aware of the fractured development.
Both of your longer-term solutions seem reasonable, and I think it depends a bit on how the next few months pan out (although it seems like you might have the ability to make the switch easier :))
With regards to... "Why use PKCS1v1.5? Why not PSS?"
I agree that we should us PSS. I think this largely came down to a time crunch as the existing dummy server only supported the following signature types.
https://github.com/letsencrypt/node-acme/blob/master/lib/crypto-util.js#L204
For reference, here is what the corresponding types refer to:
https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40#page-36
As we were rushing to complete the client demo, it was easier to use one of the supported types rather than modifying the server implementation. (The server code throws an error if you currently try to use it)
Hopefully we will transition over to the Boulder (previously called Anvil) ACME server which should be a bit more complete and the client will switch over to PSS. Thanks for the heads up though! I will add a TODO in the code.
Ayrx commentedon Jan 18, 2015
@reaperhulk Correct me if I am wrong but one option for parsing and verifying CSRs as well as self-signing X509 certs using cryptography can be to drop down to the bindings layer and use the OpenSSL API directly.
The M2crypto API isn't much more than a thin wrapper around OpenSSL anyway so using the bindings layer wouldn't be that ugly.
tdsmith commentedon Apr 15, 2015
Just a note that M2Crypto does not build with recent versions of swig, which is probably not widely packaged yet but which may eventually cause problems: https://github.com/martinpaljak/M2Crypto/issues/60
alex commentedon May 14, 2015
I just skimmed through all the crypto-library-using-code in letsencrypt. In terms of getting to "just one crypto" library here's my analysis:
PyOpenSSL is currently being used for some SSL stuff that I didn't look at too closely :-)
kuba commentedon May 15, 2015
If it is possible to move from PyCrypto to pyOpenSSL, then that would be awesome, please do so! I would happily review the patch. :) Just to make sure, have you looked at https://github.com/letsencrypt/lets-encrypt-preview/tree/master/acme package, and in particular
acme.jose.{jwk,jwa}?alex commentedon May 15, 2015
Yup :-) Cool, I'll work on that this weekend.
On Fri, May 15, 2015 at 2:18 AM, Jakub Warmuz [email protected]
wrote:
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084
alex commentedon Jul 24, 2015
It looks like this was completed by #591 and can be closed?
jdkasten commentedon Jul 24, 2015
Thanks @alex