Class DtlsSrtp
DTLS-SRTP over a datagram path, e.g. an ICE pair: a DTLS 1.2 handshake with BouncyCastle that checks the peer's certificate against its signalled fingerprint, and yields the SRTP sessions of both directions.
Implements
Inherited Members
Namespace: Uniform.Matrix.WebRtc.Dtls
Assembly: Uniform.Matrix.WebRtc.dll
Syntax
public sealed class DtlsSrtp : IDisposable
Remarks
Feed the DTLS records received, those with first bytes 20 to 63 as RFC 7983 says, to Receive(byte[]). BouncyCastle's DTLS blocks, so the handshake runs on a thread of its own, and after it a thread keeps answering retransmissions and notices the peer closing.
Constructors
| Edit this page View SourceDtlsSrtp(DtlsCertificate, bool, string, Action<byte[]>)
Prepare a handshake as client or server.
Declaration
public DtlsSrtp(DtlsCertificate certificate, bool isClient, string remoteFingerprint, Action<byte[]> send)
Parameters
| Type | Name | Description |
|---|---|---|
| DtlsCertificate | certificate | This side's certificate, whose fingerprint the local SDP carries. |
| bool | isClient | Whether this side is the DTLS client: |
| string | remoteFingerprint | The peer's |
| Action<byte[]> | send | Sends a datagram to the peer. |
Methods
| Edit this page View SourceDispose()
Send close_notify, and stop.
Declaration
public void Dispose()
HandshakeAsync(CancellationToken)
Run the handshake; return the SRTP session that protects what this side sends, and the one that unprotects what it receives.
Declaration
public Task<(SrtpSession Outbound, SrtpSession Inbound)> HandshakeAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<(SrtpSession Outbound, SrtpSession Inbound)> |
Exceptions
| Type | Condition |
|---|---|
| TlsFatalAlert | On a failed handshake, e.g. a certificate that does not match the fingerprint. |
Receive(byte[])
Give a received DTLS record to the handshake.
Declaration
public void Receive(byte[] datagram)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | datagram |
Events
| Edit this page View SourceClosed
Raised once when the peer closes DTLS, or it fails after the handshake.
Declaration
public event Action? Closed
Event Type
| Type | Description |
|---|---|
| Action |