Skip to content

Commit

Permalink
Merge pull request #54 from spectrocloud/PCP-3497
Browse files Browse the repository at this point in the history
PCP-3497 CAPV TLS 1.3 support
  • Loading branch information
sadysnaat committed Sep 18, 2024
2 parents 6b33b59 + 7423cd6 commit c991494
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
ctrlmgr "sigs.k8s.io/controller-runtime/pkg/manager"
ctrlsig "sigs.k8s.io/controller-runtime/pkg/manager/signals"

cliflag "k8s.io/component-base/cli/flag"
"sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1"
vmwarev1b1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/vmware/v1beta1"
"sigs.k8s.io/cluster-api-provider-vsphere/controllers"
Expand Down Expand Up @@ -169,7 +168,7 @@ func main() {

managerOpts.SyncPeriod = &syncPeriod

tlsOptionOverrides, err := GetTLSOptionOverrideFuncs(tlsOptions)
tlsOptionOverrides, err := GetTLSOptionOverrideFuncs()
if err != nil {
setupLog.Error(err, "unable to add TLS settings to the webhook server")
os.Exit(1)
Expand Down Expand Up @@ -241,17 +240,20 @@ func main() {

// GetTLSOptionOverrideFuncs returns a list of TLS configuration overrides to be used
// by the webhook server.
func GetTLSOptionOverrideFuncs(options TLSOptions) ([]func(*tls.Config), error) {
func GetTLSOptionOverrideFuncs() ([]func(*tls.Config), error) {
var tlsOptions []func(config *tls.Config)
var insecureSkipVerify bool
tlsVersion, err := cliflag.TLSVersion(options.TLSMinVersion)
if err != nil {
return nil, err
}

tlsOptions = append(tlsOptions, func(cfg *tls.Config) {
cfg.MinVersion = tlsVersion
cfg.CipherSuites = GetDefaultTLSCipherSuits()
// Set minimum TLS version to TLS 1.2
cfg.MinVersion = tls.VersionTLS12
cfg.MaxVersion = flags.GetTlsMaxVersion()
if cfg.MaxVersion <= tls.VersionTLS12 {
cfg.CipherSuites = GetDefaultTLSCipherSuits()
} else {
// TLS 1.3 should use its own cipher suites automatically
cfg.CipherSuites = nil
}
cfg.InsecureSkipVerify = flags.InsecureSkipVerify(insecureSkipVerify)
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/flags/tls_boring.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ func InsecureSkipVerify(insecureSkipVerify bool) bool {
}

func GetTlsMaxVersion() uint16 {
return tls.VersionTLS12
return tls.VersionTLS13
}

0 comments on commit c991494

Please sign in to comment.