RTCCertificate

DTLS certificates of a connection and the key algorithms to generate them with.

class webrtc.models.rtc_certificate.RTCCertificateExpiration(expires=None)

The lifetime of a generated certificate. It’s the base of webrtc.Algorithm.

See MDN: RTCPeerConnection/generateCertificate_static.

Parameters:

expires (int, optional) – In how many milliseconds the certificate expires, capped at a year. It’s 30 days if omitted.

class webrtc.models.rtc_certificate.Algorithm(name, *, expires=None)

A key algorithm by its WebCrypto name, for webrtc.RTCPeerConnection.generate_certificate().

'ECDSA' uses the P-256 curve. 'RSASSA-PKCS1-v1_5' needs an webrtc.RsaHashedKeyGenParams instead.

Parameters:
  • name (str) – The name, like 'ECDSA', compared case-insensitively.

  • expires (int, optional) – In how many milliseconds the certificate expires (keyword-only).

class webrtc.models.rtc_certificate.EcKeyGenParams(name, named_curve, *, expires=None)

An ECDSA key algorithm with an explicit curve.

See MDN: EcKeyGenParams.

Parameters:
  • name (str) – 'ECDSA'.

  • named_curve (str) – The curve, of which only 'P-256' is supported.

  • expires (int, optional) – In how many milliseconds the certificate expires (keyword-only).

class webrtc.models.rtc_certificate.RsaHashedKeyGenParams(name, *, modulus_length, public_exponent, hash, expires=None)

An RSA key algorithm. Every member but the name is keyword-only.

See MDN: RsaHashedKeyGenParams.

Parameters:
  • name (str) – 'RSASSA-PKCS1-v1_5'.

  • modulus_length (int) – The length of the modulus in bits, like 2048.

  • public_exponent (bytes) – The public exponent, big-endian, like bytes([1, 0, 1]) for 65537.

  • hash (str or webrtc.Algorithm) – The hash function, of which only 'SHA-256' is supported.

  • expires (int, optional) – In how many milliseconds the certificate expires.

webrtc.models.rtc_certificate.AlgorithmIdentifier

A key algorithm, or its name (like 'ECDSA'), as webrtc.RTCPeerConnection.generate_certificate() takes it

alias of str | Algorithm

class webrtc.models.rtc_certificate.RTCDtlsFingerprint(algorithm=None, value=None)

A fingerprint of a certificate, as the a=fingerprint line of SDP carries it. It’s immutable.

See MDN: RTCCertificate/getFingerprints.

Parameters:
  • algorithm (str, optional) – The hash function, like 'sha-256'.

  • value (str, optional) – The hash as lowercase hex bytes separated with colons.

class webrtc.models.rtc_certificate.RTCCertificate(native_obj=None)

A certificate and its private key, which a connection authenticates with in DTLS.

Only webrtc.RTCPeerConnection.generate_certificate() creates it, and a connection uses it through webrtc.RTCConfiguration.certificates. A connection without one generates its own. See MDN: RTCCertificate.

property expires: float

When the certificate expires, in milliseconds since the Unix epoch.

A configuration with an expired certificate raises webrtc.InvalidAccessError. See MDN: RTCCertificate/expires.

Type:

float

get_fingerprints()

Returns the fingerprints of the certificate, as the remote peer sees them in the SDP.

See MDN: RTCCertificate/getFingerprints.

Returns:

list of webrtc.RTCDtlsFingerprint – The fingerprints.

Return type:

list[RTCDtlsFingerprint]