Skip to content

Commit

Permalink
Merge branch 'vmWebhookUpdate' of github.com:rajivnathan/member-opera…
Browse files Browse the repository at this point in the history
…tor into vmWebhookUpdate
  • Loading branch information
rajivnathan committed Nov 25, 2024
2 parents b6814f8 + 5bf6481 commit 5de5ce5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"flag"
"fmt"
"net/http"
"os"
"os/signal"
Expand Down Expand Up @@ -124,14 +125,22 @@ func main() {
TLSConfig: &tls.Config{
MinVersion: tls.VersionTLS12,
NextProtos: []string{"http/1.1"}, // disable HTTP/2 for now

GetCertificate: func(_ *tls.ClientHelloInfo) (*tls.Certificate, error) {
cert, err := tls.LoadX509KeyPair("/etc/webhook/certs/"+cert.ServerCert, "/etc/webhook/certs/"+cert.ServerKey)
if err != nil {
return nil, fmt.Errorf("could not load TLS certs: %w", err)
}
return &cert, err
},
},
}

setupLog.Info("Webhook server configured.")

go func() {
setupLog.Info("Listening...")
if err := webhookServer.ListenAndServeTLS("/etc/webhook/certs/"+cert.ServerCert, "/etc/webhook/certs/"+cert.ServerKey); err != nil {
if err := webhookServer.ListenAndServeTLS("", ""); err != nil {
setupLog.Error(err, "Listening and serving TLS failed")
os.Exit(1)
}
Expand Down

0 comments on commit 5de5ce5

Please sign in to comment.