Skip to content

Commit

Permalink
Fix min tls setting for webhook server (open-telemetry#1225) (open-te…
Browse files Browse the repository at this point in the history
…lemetry#1230)

* fix min tls setting for webhook server (open-telemetry#1225)

* using constant as setting

* fix godot issue on comment
  • Loading branch information
kangsheng89 authored Nov 8, 2022
1 parent 111aa9f commit 1b2baed
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main

import (
"context"
"crypto/tls"
"flag"
"fmt"
"os"
Expand Down Expand Up @@ -50,6 +51,10 @@ import (
// +kubebuilder:scaffold:imports
)

// We should avoid that users unknowingly use a vulnerable TLS version.
// The defaults should be a safe configuration.
const defaultMinTLSVersion = tls.VersionTLS12

var (
scheme = k8sruntime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
Expand Down Expand Up @@ -151,10 +156,16 @@ func main() {
leaseDuration := time.Second * 137
renewDeadline := time.Second * 107
retryPeriod := time.Second * 26

optionsTlSOptsFuncs := []func(*tls.Config){
func(config *tls.Config) { minTlsDefault(config) },
}

mgrOptions := ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: webhookPort,
TLSOpts: optionsTlSOptsFuncs,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "9f7554c3.opentelemetry.io",
Expand Down Expand Up @@ -277,3 +288,7 @@ func addDependencies(_ context.Context, mgr ctrl.Manager, cfg config.Config, v v
}
return nil
}

func minTlsDefault(cfg *tls.Config) {
cfg.MinVersion = defaultMinTLSVersion
}

0 comments on commit 1b2baed

Please sign in to comment.