Skip to content

Commit

Permalink
Add DTLS KeyLog configuration option in WebRTC API
Browse files Browse the repository at this point in the history
Add an option in the setting engine to log TLS key material when a
DTLS connection is established with a peer.
The option exists in pion/dtls but is not easily accessible
  • Loading branch information
npmenard committed Jul 31, 2023
1 parent 457ff6c commit dfce290
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions dtlstransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error {
dtlsConfig.ExtendedMasterSecret = t.api.settingEngine.dtls.extendedMasterSecret
dtlsConfig.ClientCAs = t.api.settingEngine.dtls.clientCAs
dtlsConfig.RootCAs = t.api.settingEngine.dtls.rootCAs
dtlsConfig.KeyLogWriter = t.api.settingEngine.dtls.keyLogWriter

// Connect as DTLS Client/Server, function is blocking and we
// must not hold the DTLSTransport lock
Expand Down
7 changes: 7 additions & 0 deletions settingengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type SettingEngine struct {
clientAuth *dtls.ClientAuthType
clientCAs *x509.CertPool
rootCAs *x509.CertPool
keyLogWriter io.Writer
}
sctp struct {
maxReceiveBufferSize uint32
Expand Down Expand Up @@ -422,6 +423,12 @@ func (e *SettingEngine) SetDTLSRootCAs(rootCAs *x509.CertPool) {
e.dtls.rootCAs = rootCAs
}

// SetDTLSKeyLogWriter sets the destination of the TLS key material for debugging.
// Logging key material compromises security and should only be use for debugging.
func (e *SettingEngine) SetDTLSKeyLogWriter(writer io.Writer) {
e.dtls.keyLogWriter = writer

Check warning on line 429 in settingengine.go

View check run for this annotation

Codecov / codecov/patch

settingengine.go#L428-L429

Added lines #L428 - L429 were not covered by tests
}

// SetSCTPMaxReceiveBufferSize sets the maximum receive buffer size.
// Leave this 0 for the default maxReceiveBufferSize.
func (e *SettingEngine) SetSCTPMaxReceiveBufferSize(maxReceiveBufferSize uint32) {
Expand Down

0 comments on commit dfce290

Please sign in to comment.