Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions http.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package main

import (
"context"
"crypto/tls"
"log"
"net"
"net/http"
"strings"
"time"

"k8s.io/apiserver/pkg/server/dynamiccertificates"

oscrypto "github.com/openshift/library-go/pkg/crypto"

"github.com/openshift/oauth-proxy/util"
Expand Down Expand Up @@ -75,11 +78,19 @@ func (s *Server) ServeHTTPS() {
}

var err error
config.Certificates = make([]tls.Certificate, 1)
config.Certificates[0], err = tls.LoadX509KeyPair(s.Opts.TLSCertFile, s.Opts.TLSKeyFile)
servingCertProvider, err := dynamiccertificates.NewDynamicServingContentFromFiles("serving", s.Opts.TLSCertFile, s.Opts.TLSKeyFile)
if err != nil {
log.Fatalf("FATAL: loading tls config (%s, %s) failed - %s", s.Opts.TLSCertFile, s.Opts.TLSKeyFile, err)
}
go servingCertProvider.Run(1, context.TODO().Done())

config.GetCertificate = func(_ *tls.ClientHelloInfo) (*tls.Certificate, error) {
// this disregards information from ClientHello but we're not doing SNI anyway
cert, key := servingCertProvider.CurrentCertKeyContent()

certKeyPair, err := tls.X509KeyPair(cert, key)
return &certKeyPair, err
}

if len(s.Opts.TLSClientCAFile) > 0 {
config.ClientAuth = tls.RequestClientCert
Expand Down