Skip to content

Commit

Permalink
fix: restrict the tls cipher (#6)
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Yu <[email protected]>
  • Loading branch information
Yu-Jack authored Jan 18, 2024
1 parent a15c5da commit 8043200
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"context"
"crypto/tls"
"fmt"
"net/http"
"time"
Expand Down Expand Up @@ -31,6 +32,13 @@ var (
failPolicyFail = v1.Fail
failPolicyIgnore = v1.Ignore
sideEffectClassNone = v1.SideEffectClassNone
whiteListedCiphers = []uint16{tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
}
)

type server struct {
Expand Down Expand Up @@ -145,6 +153,10 @@ func (s *WebhookServer) listenAndServe(clients *clients.Clients, handler http.Ha
tlsName,
},
FilterCN: dynamiclistener.OnlyAllow(tlsName),
TLSConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
CipherSuites: whiteListedCiphers,
},
},
})
}
Expand Down

0 comments on commit 8043200

Please sign in to comment.