Skip to content

Commit 5b04889

Browse files
authored
Complete and validate redis.ocsp (use requests, cryptography and pyopenssl) (#9528)
1 parent c70d303 commit 5b04889

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

stubs/redis/@tests/stubtest_allowlist.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
redis.client.Pipeline.transaction # instance attribute has same name as superclass method
2-
redis.ocsp # requires cryptography to be installed
32

43
# async def mismatch problems
54
redis.asyncio.client.Pipeline.command_info

stubs/redis/METADATA.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
version = "4.4.0"
2+
# Requires a version of cryptography with a `py.typed` file
3+
requires = ["types-pyOpenSSL", "cryptography>=35.0.0"]
4+
5+
[tool.stubtest]
6+
extras = ["ocsp"]

stubs/redis/redis/ocsp.pyi

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
from typing import Any
1+
from _typeshed import Incomplete
2+
from ssl import SSLObject, SSLSocket
3+
from typing_extensions import Literal
4+
5+
from cryptography.x509.base import Certificate
6+
from OpenSSL.SSL import Connection
7+
8+
def ocsp_staple_verifier(con: Connection, ocsp_bytes: bytes, expected: bytes | None = ...) -> Literal[True]: ...
29

310
class OCSPVerifier:
4-
SOCK: Any
5-
HOST: Any
6-
PORT: Any
7-
CA_CERTS: Any
8-
def __init__(self, sock, host, port, ca_certs: Any | None = ...) -> None: ...
9-
def components_from_socket(self): ...
10-
def components_from_direct_connection(self): ...
11-
def build_certificate_url(self, server, cert, issuer_cert): ...
12-
def check_certificate(self, server, cert, issuer_url): ...
13-
def is_valid(self): ...
11+
SOCK: SSLObject | SSLSocket
12+
HOST: str
13+
PORT: int
14+
CA_CERTS: str | None
15+
def __init__(self, sock: SSLObject | SSLSocket, host: str, port: int, ca_certs: str | None = ...) -> None: ...
16+
# cryptography.x509.general_name.GeneralName.value is typed as Any
17+
def components_from_socket(self) -> tuple[Certificate, Incomplete | None, Incomplete]: ...
18+
def components_from_direct_connection(self) -> tuple[Certificate, Incomplete | None, Incomplete]: ...
19+
def build_certificate_url(self, server: str, cert: Certificate, issuer_cert: Certificate) -> str: ...
20+
def check_certificate(self, server: str, cert: Certificate, issuer_url: str | bytes) -> Literal[True]: ...
21+
def is_valid(self) -> Literal[True]: ...

0 commit comments

Comments
 (0)