-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
pyOpenSSL: Adapt to changes in 22.0.0 #7080
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
version = "21.0.*" | ||
python2 = true | ||
version = "22.0.*" | ||
requires = ["types-cryptography"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from datetime import datetime | ||
from typing import Any, Callable, Iterable, Sequence, Text, Union | ||
from typing import Any, Callable, Iterable, Sequence, Union | ||
|
||
from cryptography.hazmat.primitives.asymmetric.dsa import DSAPrivateKey, DSAPublicKey | ||
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey | ||
|
@@ -30,19 +30,19 @@ class PKey: | |
def type(self) -> int: ... | ||
|
||
class X509Name: | ||
countryName: Text | ||
C: Text | ||
stateOrProvinceName: Text | ||
ST: Text | ||
localityName: Text | ||
L: Text | ||
organizationName: Text | ||
O: Text | ||
organizationalUnitName: Text | ||
OU: Text | ||
commonName: Text | ||
CN: Text | ||
emailAddress: Text | ||
countryName: str | ||
C: str | ||
stateOrProvinceName: str | ||
ST: str | ||
localityName: str | ||
L: str | ||
organizationName: str | ||
O: str | ||
organizationalUnitName: str | ||
OU: str | ||
commonName: str | ||
CN: str | ||
emailAddress: str | ||
def __init__(self, name: X509Name) -> None: ... | ||
def der(self) -> bytes: ... | ||
def get_components(self) -> list[tuple[bytes, bytes]]: ... | ||
|
@@ -51,7 +51,7 @@ class X509Name: | |
class X509: | ||
def __init__(self) -> None: ... | ||
def add_extensions(self, extensions: Iterable[X509Extension]) -> None: ... | ||
def digest(self, digest_name: bytes) -> bytes: ... | ||
def digest(self, digest_name: str) -> bytes: ... | ||
@classmethod | ||
def from_cryptography(cls, crypto_cert: Certificate) -> X509: ... | ||
def get_extension(self, index: int) -> X509Extension: ... | ||
|
@@ -74,7 +74,7 @@ class X509: | |
def set_serial_number(self, serial: int) -> None: ... | ||
def set_subject(self, subject: X509Name) -> None: ... | ||
def set_version(self, version: int) -> None: ... | ||
def sign(self, pkey: PKey, digest: Text | bytes) -> None: ... | ||
def sign(self, pkey: PKey, digest: str) -> None: ... | ||
def subject_name_hash(self) -> bytes: ... | ||
def to_cryptography(self) -> Certificate: ... | ||
|
||
|
@@ -89,7 +89,7 @@ class X509Req: | |
def get_version(self) -> int: ... | ||
def set_pubkey(self, pkey: PKey) -> None: ... | ||
def set_version(self, version: int) -> None: ... | ||
def sign(self, pkey: PKey, digest: Text | bytes) -> None: ... | ||
def sign(self, pkey: PKey, digest: str) -> None: ... | ||
def to_cryptography(self) -> CertificateSigningRequest: ... | ||
def verify(self, pkey: PKey) -> bool: ... | ||
|
||
|
@@ -129,7 +129,7 @@ class X509Store: | |
def __init__(self) -> None: ... | ||
def add_cert(self, cert: X509) -> None: ... | ||
def add_crl(self, crl: CRL) -> None: ... | ||
def load_locations(self, cafile: Text | bytes, capath: Text | bytes | None = ...) -> None: ... | ||
def load_locations(self, cafile: str | bytes, capath: str | bytes | None = ...) -> None: ... | ||
def set_flags(self, flags: int) -> None: ... | ||
def set_time(self, vfy_time: datetime) -> None: ... | ||
|
||
|
@@ -141,7 +141,7 @@ class X509StoreContext: | |
|
||
class X509StoreContextError(Exception): | ||
certificate: X509 | ||
def __init__(self, message: Text | bytes, certificate: X509) -> None: ... | ||
def __init__(self, message: str | bytes, certificate: X509) -> None: ... | ||
|
||
class X509StoreFlags: | ||
CRL_CHECK: int | ||
|
@@ -157,7 +157,7 @@ class X509StoreFlags: | |
CB_ISSUER_CHECK: int | ||
|
||
class PKCS7: | ||
def get_type_name(self) -> Text: ... | ||
def get_type_name(self) -> str: ... | ||
def type_is_data(self) -> bool: ... | ||
def type_is_enveloped(self) -> bool: ... | ||
def type_is_signed(self) -> bool: ... | ||
|
@@ -180,24 +180,24 @@ class NetscapeSPKI: | |
def b64_encode(self) -> bytes: ... | ||
def get_pubkey(self) -> PKey: ... | ||
def set_pubkey(self, pkey: PKey) -> None: ... | ||
def sign(self, pkey: PKey, digest: bytes) -> None: ... | ||
def sign(self, pkey: PKey, digest: str) -> None: ... | ||
def verify(self, key: PKey) -> bool: ... | ||
|
||
def get_elliptic_curves() -> set[_EllipticCurve]: ... | ||
def get_elliptic_curve(name: Text) -> _EllipticCurve: ... | ||
def get_elliptic_curve(name: str) -> _EllipticCurve: ... | ||
def dump_certificate(type: int, cert: X509) -> bytes: ... | ||
def load_certificate(type: int, buffer: bytes) -> X509: ... | ||
def dump_certificate_request(type: int, req: X509Req) -> bytes: ... | ||
def load_certificate_request(type: int, buffer: bytes) -> X509Req: ... | ||
def dump_privatekey( | ||
type: int, pkey: PKey, cipher: bytes | None = ..., passphrase: bytes | Callable[[], bytes] | None = ... | ||
type: int, pkey: PKey, cipher: str | None = ..., passphrase: bytes | Callable[[], bytes] | None = ... | ||
) -> bytes: ... | ||
def load_privatekey(type: int, buffer: Text | bytes, passphrase: bytes | Callable[[], bytes] | None = ...) -> PKey: ... | ||
def load_privatekey(type: int, buffer: str | bytes, passphrase: bytes | Callable[[], bytes] | None = ...) -> PKey: ... | ||
def dump_publickey(type: int, pkey: PKey) -> bytes: ... | ||
def load_publickey(type: int, buffer: Text | bytes) -> PKey: ... | ||
def load_publickey(type: int, buffer: str | bytes) -> PKey: ... | ||
def dump_crl(type: int, crl: CRL) -> bytes: ... | ||
def load_crl(type: int, buffer: Text | bytes) -> CRL: ... | ||
def load_pkcs7_data(type: int, buffer: Text | bytes) -> PKCS7: ... | ||
def load_pkcs12(buffer: Text | bytes, passphrase: bytes | None = ...) -> PKCS12: ... | ||
def sign(pkey: PKey, data: Text | bytes, digest: Text | bytes) -> bytes: ... | ||
def verify(cert: X509, signature: bytes, data: Text | bytes, digest: Text | bytes) -> None: ... | ||
def load_crl(type: int, buffer: str | bytes) -> CRL: ... | ||
def load_pkcs7_data(type: int, buffer: str | bytes) -> PKCS7: ... | ||
def load_pkcs12(buffer: str | bytes, passphrase: bytes | None = ...) -> PKCS12: ... | ||
def sign(pkey: PKey, data: str | bytes, digest: str) -> bytes: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idea for future PR: Some arguments, such as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Im curious, is this a standard thing done in the typing community? This seems to force application maintainers into one of the following options if they use a deprecated type
Don’t seem very good options to me Especially because DeprecationWarnings can be catched by unittests. But i don’t have much experience with typing so maybe this is standard procedure in the community and its not a big deal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We currently don't have a good way to mark deprecated things. There's some discussion about this here: python/typing#1043 For now, we usually keep deprecated things in the spirit of avoiding false positives. This was just a random idea. |
||
def verify(cert: X509, signature: bytes, data: str | bytes, digest: str) -> None: ... |
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.
cafile
andcapath
should be annotated with_typeshed.StrOrBytesPath
. They get passed to_path_bytes
which callsos.fspath
.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.
I added the suggestions