Skip to content

Commit 448f4ba

Browse files
npmenardedaniels
authored andcommitted
Add DTLS KeyLog configuration option in WebRTC API
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
1 parent 457ff6c commit 448f4ba

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

dtlstransport.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error {
342342
dtlsConfig.ExtendedMasterSecret = t.api.settingEngine.dtls.extendedMasterSecret
343343
dtlsConfig.ClientCAs = t.api.settingEngine.dtls.clientCAs
344344
dtlsConfig.RootCAs = t.api.settingEngine.dtls.rootCAs
345+
dtlsConfig.KeyLogWriter = t.api.settingEngine.dtls.keyLogWriter
345346

346347
// Connect as DTLS Client/Server, function is blocking and we
347348
// must not hold the DTLSTransport lock

settingengine.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ type SettingEngine struct {
7171
clientAuth *dtls.ClientAuthType
7272
clientCAs *x509.CertPool
7373
rootCAs *x509.CertPool
74+
keyLogWriter io.Writer
7475
}
7576
sctp struct {
7677
maxReceiveBufferSize uint32
@@ -422,6 +423,12 @@ func (e *SettingEngine) SetDTLSRootCAs(rootCAs *x509.CertPool) {
422423
e.dtls.rootCAs = rootCAs
423424
}
424425

426+
// SetDTLSKeyLogWriter sets the destination of the TLS key material for debugging.
427+
// Logging key material compromises security and should only be use for debugging.
428+
func (e *SettingEngine) SetDTLSKeyLogWriter(writer io.Writer) {
429+
e.dtls.keyLogWriter = writer
430+
}
431+
425432
// SetSCTPMaxReceiveBufferSize sets the maximum receive buffer size.
426433
// Leave this 0 for the default maxReceiveBufferSize.
427434
func (e *SettingEngine) SetSCTPMaxReceiveBufferSize(maxReceiveBufferSize uint32) {

0 commit comments

Comments
 (0)