rnet.tls
TLS/SSL configuration including certificates, key logging, and fingerprinting.
rnet.tls
TLS Utilities and Types
This module provides types and utilities for configuring TLS (Transport Layer Security) in HTTP clients.
TlsVersion
AlpnProtocol
AlpsProtocol
CertificateCompressionAlgorithm
Bases: Enum
IANA assigned identifier of compression algorithm. See https://www.rfc-editor.org/rfc/rfc8879.html#name-compression-algorithms
Source code in rnet/tls.py
ExtensionType
Bases: Enum
A TLS extension type.
Source code in rnet/tls.py
Identity
Represents a private key and X509 cert as a client certificate.
Source code in rnet/tls.py
from_pkcs12_der
staticmethod
Parses a DER-formatted PKCS #12 archive, using the specified password to decrypt the key.
The archive should contain a leaf certificate and its private key, as well any intermediate certificates that allow clients to build a chain to a trusted root. The chain certificates should be in order from the leaf certificate towards the root.
PKCS #12 archives typically have the file extension .p12 or .pfx, and can be created
with the OpenSSL pkcs12 tool:
openssl pkcs12 -export -out identity.pfx -inkey key.pem -in cert.pem -certfile chain_certs.pem
Source code in rnet/tls.py
from_pkcs8_pem
staticmethod
Parses a chain of PEM encoded X509 certificates, with the leaf certificate first.
key is a PEM encoded PKCS #8 formatted private key for the leaf certificate.
The certificate chain should contain any intermediate certificates that should be sent to clients to allow them to build a chain to a trusted root.
A certificate chain here means a series of PEM encoded certificates concatenated together.
Source code in rnet/tls.py
CertStore
Represents a certificate store for verifying TLS connections.
Source code in rnet/tls.py
__init__
Creates a new CertStore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
der_certs
|
Sequence[bytes] | None
|
Optional list of DER-encoded certificates (as bytes). |
None
|
pem_certs
|
Sequence[str] | None
|
Optional list of PEM-encoded certificates (as str). |
None
|
default_paths
|
bool | None
|
If True, use system default certificate paths. |
None
|
Source code in rnet/tls.py
from_der_certs
staticmethod
Creates a CertStore from a collection of DER-encoded certificates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
certs
|
Sequence[bytes]
|
List of DER-encoded certificates (as bytes). |
required |
from_pem_certs
staticmethod
Creates a CertStore from a collection of PEM-encoded certificates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
certs
|
Sequence[str]
|
List of PEM-encoded certificates (as str). |
required |
from_pem_stack
staticmethod
Creates a CertStore from a PEM-encoded certificate stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
certs
|
bytes
|
PEM-encoded certificate stack (as bytes). |
required |
KeyLog
Specifies the intent for a (TLS) keylogger to be used in a client or server configuration.
This type allows you to control how TLS session keys are logged for debugging or analysis. You can either use the default environment variable (SSLKEYLOGFILE) or specify a file path directly. This is useful for tools like Wireshark that can decrypt TLS traffic if provided with the correct session keys.
Static Methods
environment() -> KeyLog Use the SSLKEYLOGFILE environment variable for key logging. file(path: Path) -> KeyLog Log keys to the specified file path.
Source code in rnet/tls.py
environment
staticmethod
file
staticmethod
Log keys to the specified file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str
|
The file path to log TLS keys to. |
required |
Params
Bases: TypedDict
All parameters for TLS connections.
Source code in rnet/tls.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | |
alpn_protocols
instance-attribute
Application-Layer Protocol Negotiation (RFC 7301).
Specifies which application protocols (e.g., HTTP/2, HTTP/1.1) may be negotiated over a single TLS connection.
alps_protocols
instance-attribute
Application-Layer Protocol Settings (ALPS).
Enables exchanging application-layer settings during the handshake for protocols negotiated via ALPN.
alps_use_new_codepoint
instance-attribute
Whether to use an alternative ALPS codepoint for compatibility.
Useful when larger ALPS payloads are required.
session_ticket
instance-attribute
Enables TLS Session Tickets (RFC 5077).
Allows session resumption without requiring server-side state.
pre_shared_key
instance-attribute
Enables Pre-Shared Key (PSK) cipher suites (RFC 4279).
Authentication relies on out-of-band pre-shared keys instead of certificates.
enable_ech_grease
instance-attribute
Controls whether to send a GREASE Encrypted ClientHello (ECH) extension when no supported ECH configuration is available.
GREASE prevents protocol ossification by sending unknown extensions.
permute_extensions
instance-attribute
Controls whether ClientHello extensions should be permuted.
grease_enabled
instance-attribute
Controls whether GREASE extensions (RFC 8701) are enabled in general.
enable_ocsp_stapling
instance-attribute
Enables OCSP stapling for the connection.
enable_signed_cert_timestamps
instance-attribute
Enables Signed Certificate Timestamps (SCT).
psk_skip_session_ticket
instance-attribute
Whether to skip session tickets when using PSK.
key_shares_limit
instance-attribute
Maximum number of key shares to include in ClientHello.
renegotiation
instance-attribute
Enables TLS renegotiation by sending the renegotiation_info extension.
delegated_credentials
instance-attribute
Delegated Credentials (RFC 9345).
Allows TLS 1.3 endpoints to use temporary delegated credentials for authentication with reduced long-term key exposure.
cipher_list
instance-attribute
Cipher suite configuration string.
Uses BoringSSL's mini-language to select, enable, and prioritize ciphers.
certificate_compression_algorithms
instance-attribute
Supported certificate compression algorithms (RFC 8879).
extension_permutation
instance-attribute
Supported TLS extensions, used for extension ordering/permutation.
random_aes_hw_override
instance-attribute
Overrides the random AES hardware acceleration.
preserve_tls13_cipher_list
instance-attribute
Sets whether to preserve the TLS 1.3 cipher list as configured by cipher_list.
By default, BoringSSL does not preserve the TLS 1.3 cipher list. When this option is disabled (the default), BoringSSL uses its internal default TLS 1.3 cipher suites in its default order, regardless of what is set via cipher_list.
When enabled, this option ensures that the TLS 1.3 cipher suites explicitly set via cipher_list are retained in their original order, without being reordered or modified by BoringSSL's internal logic. This is useful for maintaining specific cipher suite priorities for TLS 1.3. Note that if cipher_list does not include any TLS 1.3 cipher suites, BoringSSL will still fall back to its default TLS 1.3 cipher suites and order.
TlsOptions
TLS connection configuration options.
This struct provides fine-grained control over the behavior of TLS connections, including: - Protocol negotiation (ALPN, ALPS, TLS versions) - Session management (tickets, PSK, key shares) - Security & privacy (OCSP, GREASE, ECH, delegated credentials) - Performance tuning (record size, cipher preferences, hardware overrides)
All fields are optional or have defaults. See each field for details.
Source code in rnet/tls.py
TlsInfo
Information about the established TLS connection.