File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -340,6 +340,7 @@ func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error { //nolint:
340340 ClientAuth : dtls .RequireAnyClientCert ,
341341 LoggerFactory : t .api .settingEngine .LoggerFactory ,
342342 InsecureSkipVerify : ! t .api .settingEngine .dtls .disableInsecureSkipVerify ,
343+ CipherSuites : t .api .settingEngine .dtls .cipherSuites ,
343344 CustomCipherSuites : t .api .settingEngine .dtls .customCipherSuites ,
344345 }, nil
345346 }
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ type SettingEngine struct {
7474 clientCAs * x509.CertPool
7575 rootCAs * x509.CertPool
7676 keyLogWriter io.Writer
77+ cipherSuites []dtls.CipherSuiteID
7778 customCipherSuites func () []dtls.CipherSuite
7879 clientHelloMessageHook func (handshake.MessageClientHello ) handshake.Message
7980 serverHelloMessageHook func (handshake.MessageServerHello ) handshake.Message
@@ -497,8 +498,15 @@ func (e *SettingEngine) SetSCTPMaxMessageSize(maxMessageSize uint32) {
497498 e .sctp .maxMessageSize = maxMessageSize
498499}
499500
500- // SetDTLSCustomerCipherSuites allows the user to specify a list of DTLS CipherSuites.
501- // This allow usage of Ciphers that are reserved for private usage.
501+ // SetDTLSCipherSuites allows the user to specify a list of DTLS CipherSuites.
502+ // This allow to control which ciphers implemented by pion/dtls are used during the DTLS handshake.
503+ // It can be used for DTLS connection hardening.
504+ func (e * SettingEngine ) SetDTLSCipherSuites (cipherSuites ... dtls.CipherSuiteID ) {
505+ e .dtls .cipherSuites = cipherSuites
506+ }
507+
508+ // SetDTLSCustomerCipherSuites allows the user to specify a list of custom DTLS CipherSuites.
509+ // It allows to use custom/private DTLS CipherSuites in addition to the ones implemented by pion/dtls.
502510func (e * SettingEngine ) SetDTLSCustomerCipherSuites (customCipherSuites func () []dtls.CipherSuite ) {
503511 e .dtls .customCipherSuites = customCipherSuites
504512}
Original file line number Diff line number Diff line change @@ -586,6 +586,7 @@ func TestSettingEngine_DTLSSetters(t *testing.T) {
586586 se .SetDTLSClientCAs (clientCAs )
587587 se .SetDTLSRootCAs (rootCAs )
588588 se .SetDTLSKeyLogWriter (& keyBuf )
589+ se .SetDTLSCipherSuites (dtls .TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 , dtls .TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 )
589590
590591 called := false
591592 se .SetDTLSCustomerCipherSuites (func () []dtls.CipherSuite {
@@ -603,6 +604,10 @@ func TestSettingEngine_DTLSSetters(t *testing.T) {
603604 assert .Equal (t , rootCAs , se .dtls .rootCAs )
604605 _ , _ = se .dtls .keyLogWriter .Write ([]byte ("test" ))
605606 assert .NotZero (t , keyBuf .Len ())
607+ assert .Equal (t , []dtls.CipherSuiteID {
608+ dtls .TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 ,
609+ dtls .TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 ,
610+ }, se .dtls .cipherSuites )
606611 _ = se .dtls .customCipherSuites ()
607612 assert .True (t , called )
608613}
You can’t perform that action at this time.
0 commit comments