pyca / pyopenssl

A Python wrapper around the OpenSSL library
https://pyopenssl.org/
Apache License 2.0
889 stars 419 forks source link

Deprecate passing `PKey` instances to `use_privatekey` #1348

Closed alex closed 3 months ago

alex commented 3 months ago

Allow passing cryptography keys instead.

Refs #1321

alex commented 3 months ago

Not on older pythons

On Tue, Aug 6, 2024, 9:30 AM Maximilian Hils @.***> wrote:

@.**** commented on this pull request.

In src/OpenSSL/crypto.py https://github.com/pyca/pyopenssl/pull/1348#discussion_r1705544665:

@@ -84,6 +84,14 @@ ]

+_PrivateKey = Union[

  • dsa.DSAPrivateKey,
  • ec.EllipticCurvePrivateKey,
  • ed25519.Ed25519PrivateKey,
  • ed448.Ed448PrivateKey,
  • rsa.RSAPrivateKey, +] +# TODO: Turn this into PublicKey | PrivateKey once we use |.

Can't we do that right away?

a = Union[1,2]>>> b = Union[3,4]>>> Union[a,b]typing.Union[1, 2, 3, 4]

— Reply to this email directly, view it on GitHub https://github.com/pyca/pyopenssl/pull/1348#pullrequestreview-2221317782, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAGBBY3S7BWLDZBWCFBQ3ZQDFYRAVCNFSM6AAAAABMCHLMESVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDEMRRGMYTONZYGI . You are receiving this because you authored the thread.Message ID: @.***>

mhils commented 3 months ago
> docker run --rm -it python:3.7.0
Python 3.7.0 (default, Oct 16 2018, 07:10:55)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import Union
>>> a = Union[str, int]
>>> b = Union[bool, float]
>>> Union[a,b]
typing.Union[str, int, bool, float]

This looks ok to me? (I've also tested 3.8-3.10)

alex commented 3 months ago

Ohhh, yeah, i guess I didn't try that. Will fix this evening

On Tue, Aug 6, 2024, 9:59 AM Maximilian Hils @.***> wrote:

docker run --rm -it python:3.7.0Python 3.7.0 (default, Oct 16 2018, 07:10:55) [GCC 6.3.0 20170516] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from typing import Union>>> a = Union[str, int]>>> b = Union[bool, float]>>> Union[a,b]typing.Union[str, int, bool, float]

This looks ok to me? (I've also tested 3.8-3.10)

— Reply to this email directly, view it on GitHub https://github.com/pyca/pyopenssl/pull/1348#issuecomment-2271369616, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAGBGRHDB6NUZTWY26CB3ZQDJFJAVCNFSM6AAAAABMCHLMESVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZRGM3DSNRRGY . You are receiving this because you authored the thread.Message ID: @.***>