ssl
ssl
¶
NIP-66 SSL metadata container with certificate inspection capabilities.
Connects to a relay's TLS endpoint, extracts certificate details (subject, issuer, validity, SANs, fingerprint, cipher), and separately validates the certificate chain as part of NIP-66 monitoring. Clearnet relays only.
Note
The SSL test uses a two-connection methodology:
- Extraction -- connects with
CERT_NONEto obtain the DER-encoded certificate regardless of chain validity, then parses it with thecryptographylibrary. This allows inspecting self-signed or expired certificates. - Validation -- connects with the default (validating) SSL context to verify the certificate chain against the system trust store.
Both connections are synchronous socket operations delegated to a thread
pool via asyncio.to_thread to avoid blocking the event loop.
See Also
bigbrotr.nips.nip66.data.Nip66SslData: Data model for SSL certificate fields. bigbrotr.nips.nip66.logs.Nip66SslLogs: Log model for SSL inspection results. bigbrotr.utils.transport.InsecureWebSocketTransport: Related insecure transport used for WebSocket connections (distinct from the raw socket approach used here for certificate extraction).
Classes¶
CertificateExtractor
¶
Extracts structured fields from SSL certificates.
Uses cryptography X.509 objects (from DER-encoded certificates)
and raw DER bytes for fingerprint computation.
See Also
Nip66SslMetadata: Container that uses this extractor during certificate inspection. bigbrotr.nips.nip66.data.Nip66SslData: Data model populated by the extracted fields.
Functions¶
extract_fingerprint
staticmethod
¶
Compute a SHA-256 fingerprint from the DER-encoded certificate.
Returns:
-
str–Colon-separated hex string prefixed with
SHA256:.
Source code in src/bigbrotr/nips/nip66/ssl.py
extract_all_from_x509
classmethod
¶
Extract all fields from a cryptography X.509 certificate object.
Source code in src/bigbrotr/nips/nip66/ssl.py
Nip66SslMetadata
¶
Bases: BaseNipMetadata
Container for SSL/TLS certificate data and inspection logs.
Provides the execute() class method that performs certificate
extraction and chain validation against a relay's TLS endpoint.
Warning
The certificate extraction phase uses CERT_NONE to read
certificates from relays with invalid chains. This is intentional
for monitoring purposes and does not affect the ssl_valid field,
which is determined by a separate validating connection.
See Also
bigbrotr.nips.nip66.nip66.Nip66:
Top-level model that orchestrates this alongside other tests.
bigbrotr.models.metadata.MetadataType:
The NIP66_SSL variant used when storing these results.
bigbrotr.nips.nip66.rtt.Nip66RttMetadata:
RTT test that also involves SSL connections.
Functions¶
execute
async
classmethod
¶
execute(relay: Relay, timeout: float | None = None) -> Self
Inspect the SSL/TLS certificate of a clearnet relay.
Runs the synchronous SSL operations in a thread pool to avoid blocking the event loop.
Parameters:
-
relay(Relay) –Clearnet relay to inspect.
-
timeout(float | None, default:None) –Socket timeout in seconds (default: 10.0).
Returns:
-
Self–An
Nip66SslMetadatainstance with certificate data and logs.