2 from typing import Any, Callable, Sequence
4 from OpenSSL.crypto import X509, PKey
6 OPENSSL_VERSION_NUMBER: int
14 RECEIVED_SHUTDOWN: int
24 TLS_SERVER_METHOD: int
25 TLS_CLIENT_METHOD: int
40 MODE_RELEASE_BUFFERS: int
43 OP_SINGLE_ECDH_USE: int
45 OP_MICROSOFT_SESS_ID_BUG: int
46 OP_NETSCAPE_CHALLENGE_BUG: int
47 OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: int
49 OP_SSLREF2_REUSE_CERT_TYPE_BUG: int
50 OP_MICROSOFT_BIG_SSLV3_BUFFER: int
51 OP_MSIE_SSLV2_RSA_PADDING: int
52 OP_SSLEAY_080_CLIENT_DH_BUG: int
54 OP_TLS_BLOCK_PADDING_BUG: int
55 OP_DONT_INSERT_EMPTY_FRAGMENTS: int
56 OP_CIPHER_SERVER_PREFERENCE: int
57 OP_TLS_ROLLBACK_BUG: int
60 OP_NETSCAPE_CA_DN_BUG: int
61 OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: int
63 OP_NO_COMPRESSION: int
66 OP_COOKIE_EXCHANGE: int
72 VERIFY_FAIL_IF_NO_PEER_CERT: int
73 VERIFY_CLIENT_ONCE: int
77 SESS_CACHE_CLIENT: int
78 SESS_CACHE_SERVER: int
80 SESS_CACHE_NO_AUTO_CLEAR: int
81 SESS_CACHE_NO_INTERNAL_LOOKUP: int
82 SESS_CACHE_NO_INTERNAL_STORE: int
83 SESS_CACHE_NO_INTERNAL: int
94 SSL_CB_READ_ALERT: int
95 SSL_CB_WRITE_ALERT: int
96 SSL_CB_ACCEPT_LOOP: int
97 SSL_CB_ACCEPT_EXIT: int
98 SSL_CB_CONNECT_LOOP: int
99 SSL_CB_CONNECT_EXIT: int
100 SSL_CB_HANDSHAKE_START: int
101 SSL_CB_HANDSHAKE_DONE: int
103 NO_OVERLAPPING_PROTOCOLS: object
105 class Error(Exception): ...
106 class WantReadError(Error): ...
107 class WantWriteError(Error): ...
108 class WantX509LookupError(Error): ...
109 class ZeroReturnError(Error): ...
110 class SysCallError(Error): ...
112 def SSLeay_version(type: int) -> str: ...
114 class Session(object): ...
116 class Connection(object):
117 def __getattr__(self, name: str) -> Any: ... # incomplete
118 def __init__(self, context: Context, socket: socket.socket | None = ...) -> None: ...
119 def connect(self, addr: str | bytes | Sequence[str | int]) -> None: ...
120 def do_handshake(self) -> None: ...
121 def get_peer_certificate(self) -> X509: ...
122 def set_tlsext_host_name(self, name: bytes) -> None: ...
123 def bio_read(self, bufsiz: int) -> bytes: ...
124 def bio_write(self, buf: bytes) -> int: ...
125 def recv(self, bufsiz: int, flags: int | None = ...) -> bytes: ...
126 def sendall(self, buf: bytes, flags: int = ...) -> int: ...
127 def set_accept_state(self) -> None: ...
128 def set_connect_state(self) -> None: ...
129 def get_peer_cert_chain(self) -> list[X509]: ...
130 def get_alpn_proto_negotiated(self) -> bytes: ...
131 def get_cipher_name(self) -> str | None: ...
132 def get_protocol_version_name(self) -> str: ...
133 def get_shutdown(self) -> int: ...
134 def get_app_data(self) -> Any: ...
135 def set_app_data(self, data: Any) -> None: ...
137 class Context(object):
138 def __getattr__(self, name: str) -> Any: ... # incomplete
139 def __init__(self, method: int) -> None: ...
140 def load_verify_locations(self, cafile: str | None, capath: str | None = ...) -> None: ...
141 def set_options(self, options: int) -> None: ...
142 def set_verify(self, mode: int, callback: Callable[[Connection, X509, int, int, int], bool] | None = ...) -> None: ...
143 # will be added in pyOpenSSL 21
144 # def set_min_proto_version(self, version: int) -> None: ...
145 # def set_max_proto_version(self, version: int) -> None: ...
146 def use_certificate_chain_file(self, certfile: str | bytes) -> None: ...
147 def use_certificate_file(self, certfile: str | bytes, filetype: int = ...) -> None: ...
148 def use_certificate(self, cert: X509) -> None: ...
149 def use_privatekey_file(self, keyfile: str | bytes, filetype: int | None = ...) -> None: ...
150 def use_privatekey(self, pkey: PKey) -> None: ...
151 def add_extra_chain_cert(self, certobj: X509) -> None: ...
152 def set_cipher_list(self, cipher_list: bytes) -> None: ...
153 def set_keylog_callback(self, callback: Callable[[Connection, bytes], None]) -> None: ...
154 def set_alpn_protos(self, protos: Sequence[bytes]) -> None: ...
155 def set_alpn_select_callback(self, callback: Callable[[Connection, list[bytes]], bytes]) -> None: ...