-
Notifications
You must be signed in to change notification settings - Fork 419
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
Allow loading EC, ED25519, ED448 public keys from cryptography #1310
Conversation
This also fixes our type annotations, which did not mention we support |
I now notice this seems to overlap with #636 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reaperhulk do you remember if there's a reason we did rsa/dsa only originally?
Our code is quite capable of supporting these public key types, so allow users to do so. We also beef up the test suite to test all these key types, along with DSA keys which were not explicitly tested.
4f638d5
to
6a0b519
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, pending @reaperhulk confirming that there wasn't a good reason we limited this.
For context I was trying to eliminate I then noticed how asymmetrical (heh) the behaviour was: for DSA and RSA we supported both private keys and public keys, for |
The |
I think it's true that you can't use |
Thanks @alex ! Should I submit a follow up PR that mentions both my changes in the changelog? Sorry for not doing that inline in the PRs! Is 24.2.0 the next version? |
Ooops, yes, changelog would be good. |
24.2.1 (2024-07-20) ------------------- Changes: ^^^^^^^^ - Fixed changelog to remove sphinx specific restructured text strings. 24.2.0 (2024-07-20) ------------------- Deprecations: ^^^^^^^^^^^^^ - Deprecated ``OpenSSL.crypto.X509Req``, ``OpenSSL.crypto.load_certificate_request``, ``OpenSSL.crypto.dump_certificate_request``. Instead, ``cryptography.x509.CertificateSigningRequest``, ``cryptography.x509.CertificateSigningRequestBuilder``, ``cryptography.x509.load_der_x509_csr``, or ``cryptography.x509.load_pem_x509_csr`` should be used. Changes: ^^^^^^^^ - Added type hints for the ``SSL`` module. `#1308 <https://github.com/pyca/pyopenssl/pull/1308>`_. - Changed ``OpenSSL.crypto.PKey.from_cryptography_key`` to accept public and private EC, ED25519, ED448 keys. `#1310 <https://github.com/pyca/pyopenssl/pull/1310>`_.
Bumps [pyopenssl](https://github.com/pyca/pyopenssl) from 24.1.0 to 24.2.1. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/pyca/pyopenssl/blob/main/CHANGELOG.rst">pyopenssl's changelog</a>.</em></p> <blockquote> <h2>24.2.1 (2024-07-20)</h2> <p>Backward-incompatible changes: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p> <p>Deprecations: ^^^^^^^^^^^^^</p> <p>Changes: ^^^^^^^^</p> <ul> <li>Fixed changelog to remove sphinx specific restructured text strings.</li> </ul> <h2>24.2.0 (2024-07-20)</h2> <p>Backward-incompatible changes: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p> <p>Deprecations: ^^^^^^^^^^^^^</p> <ul> <li>Deprecated <code>OpenSSL.crypto.X509Req</code>, <code>OpenSSL.crypto.load_certificate_request</code>, <code>OpenSSL.crypto.dump_certificate_request</code>. Instead, <code>cryptography.x509.CertificateSigningRequest</code>, <code>cryptography.x509.CertificateSigningRequestBuilder</code>, <code>cryptography.x509.load_der_x509_csr</code>, or <code>cryptography.x509.load_pem_x509_csr</code> should be used.</li> </ul> <p>Changes: ^^^^^^^^</p> <ul> <li>Added type hints for the <code>SSL</code> module. <code>[#1308](pyca/pyopenssl#1308) <https://github.com/pyca/pyopenssl/pull/1308></code>_.</li> <li>Changed <code>OpenSSL.crypto.PKey.from_cryptography_key</code> to accept public and private EC, ED25519, ED448 keys. <code>[#1310](pyca/pyopenssl#1310) <https://github.com/pyca/pyopenssl/pull/1310></code>_.</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/pyca/pyopenssl/commit/8dd94578656d47f854c087783b72431aaeb73d8e"><code>8dd9457</code></a> 24.2.1 (<a href="https://redirect.github.com/pyca/pyopenssl/issues/1320">#1320</a>)</li> <li><a href="https://github.com/pyca/pyopenssl/commit/19f093e0c3db5d7354df0a5256344d9ebc5d931f"><code>19f093e</code></a> make changelog vanilla rst (<a href="https://redirect.github.com/pyca/pyopenssl/issues/1319">#1319</a>)</li> <li><a href="https://github.com/pyca/pyopenssl/commit/e265b2867bbc4f45a14b31affe4a0be710d2b293"><code>e265b28</code></a> Prepare for 24.2.0 release (<a href="https://redirect.github.com/pyca/pyopenssl/issues/1318">#1318</a>)</li> <li><a href="https://github.com/pyca/pyopenssl/commit/6943ee524e511138dd78fde6000e6f8e2bdd4b0c"><code>6943ee5</code></a> Deprecate CSR support in pyOpenSSL (<a href="https://redirect.github.com/pyca/pyopenssl/issues/1316">#1316</a>)</li> <li><a href="https://github.com/pyca/pyopenssl/commit/01b9b5637318bde2490e3f8bb243723546dbcc62"><code>01b9b56</code></a> Add more type definitions for <code>SSL</code> module, check with mypy (<a href="https://redirect.github.com/pyca/pyopenssl/issues/1313">#1313</a>)</li> <li><a href="https://github.com/pyca/pyopenssl/commit/cdcb48baf7d5dd0f040f244934c2967b04b9f4bc"><code>cdcb48b</code></a> Prune redundant <code>:rtype:</code> from SSL module (<a href="https://redirect.github.com/pyca/pyopenssl/issues/1315">#1315</a>)</li> <li><a href="https://github.com/pyca/pyopenssl/commit/b86914d37fc6c0e138e2a0f733dd65dec2efc96c"><code>b86914d</code></a> Fix <code>ruff</code> invocation (<a href="https://redirect.github.com/pyca/pyopenssl/issues/1314">#1314</a>)</li> <li><a href="https://github.com/pyca/pyopenssl/commit/caa1ab3ac5c5096b20b69fac2e42cb67c6f716d1"><code>caa1ab3</code></a> Update changelog for PR <a href="https://redirect.github.com/pyca/pyopenssl/issues/1308">#1308</a> and <a href="https://redirect.github.com/pyca/pyopenssl/issues/1310">#1310</a> (<a href="https://redirect.github.com/pyca/pyopenssl/issues/1311">#1311</a>)</li> <li><a href="https://github.com/pyca/pyopenssl/commit/9a2105501f601798bb2fb1928cee5ed8b21e32e4"><code>9a21055</code></a> Allow loading EC, ED25519, ED448 public keys from cryptography (<a href="https://redirect.github.com/pyca/pyopenssl/issues/1310">#1310</a>)</li> <li><a href="https://github.com/pyca/pyopenssl/commit/9eaa1073621dd46b3e721183efc318c95aba0d74"><code>9eaa107</code></a> Add type annotations for the <code>SSL</code> module (<a href="https://redirect.github.com/pyca/pyopenssl/issues/1308">#1308</a>)</li> <li>Additional commits viewable in <a href="https://github.com/pyca/pyopenssl/compare/24.1.0...24.2.1">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pyopenssl&package-manager=pip&previous-version=24.1.0&new-version=24.2.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Our code is quite capable of supporting these public key types, so allow users to do so.
We also beef up the test suite to test all these key types, along with DSA keys which were not explicitly tested.