Skip to content

Commit c39d81d

Browse files
committed
use the extraClientCA as it was intended
1 parent a7810e0 commit c39d81d

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

pkg/cmd/server/api/helpers.go

+19
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ func GetMasterFileReferences(config *MasterConfig) []*string {
241241
refs = append(refs, &config.KubernetesMasterConfig.ProxyClientInfo.KeyFile)
242242
}
243243

244+
if config.AuthConfig.RequestHeader != nil {
245+
refs = append(refs, &config.AuthConfig.RequestHeader.ClientCA)
246+
}
247+
244248
refs = append(refs, &config.ServiceAccountConfig.MasterCA)
245249
refs = append(refs, &config.ServiceAccountConfig.PrivateKeyFile)
246250
for i := range config.ServiceAccountConfig.PublicKeyFiles {
@@ -457,6 +461,21 @@ func GetOAuthClientCertCAs(options MasterConfig) ([]*x509.Certificate, error) {
457461
return allCerts, nil
458462
}
459463

464+
func GetRequestHeaderClientCertCAs(options MasterConfig) ([]*x509.Certificate, error) {
465+
if !UseTLS(options.ServingInfo.ServingInfo) {
466+
return nil, nil
467+
}
468+
if options.AuthConfig.RequestHeader == nil {
469+
return nil, nil
470+
}
471+
472+
certs, err := cmdutil.CertificatesFromFile(options.AuthConfig.RequestHeader.ClientCA)
473+
if err != nil {
474+
return nil, fmt.Errorf("Error reading %s: %s", options.AuthConfig.RequestHeader.ClientCA, err)
475+
}
476+
return certs, nil
477+
}
478+
460479
func getAPIClientCertCAs(options MasterConfig) ([]*x509.Certificate, error) {
461480
if !UseTLS(options.ServingInfo.ServingInfo) {
462481
return nil, nil

pkg/cmd/server/kubernetes/master_config.go

+8-10
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,6 @@ func BuildDefaultAPIServer(options configapi.MasterConfig) (*apiserveroptions.Se
114114
server.GenericServerRunOptions.TLSPrivateKeyFile = options.ServingInfo.ServerCert.KeyFile
115115
server.GenericServerRunOptions.ClientCAFile = options.ServingInfo.ClientCA
116116

117-
// TODO this is a terrible hack that should be removed in 1.6
118-
if options.AuthConfig.RequestHeader != nil {
119-
clientCAFile, err := concatenateFiles("cafrontproxybundle", "\n", options.ServingInfo.ClientCA, options.AuthConfig.RequestHeader.ClientCA)
120-
if err != nil {
121-
return nil, nil, fmt.Errorf("unable to create ca bundle temp file: %v", err)
122-
}
123-
glog.V(2).Infof("temp clientCA bundle file is %s", clientCAFile)
124-
server.GenericServerRunOptions.ClientCAFile = clientCAFile
125-
}
126-
127117
server.GenericServerRunOptions.MaxRequestsInFlight = options.ServingInfo.MaxRequestsInFlight
128118
server.GenericServerRunOptions.MinRequestTimeout = options.ServingInfo.RequestTimeoutSeconds
129119
for _, nc := range options.ServingInfo.NamedCertificates {
@@ -314,6 +304,14 @@ func BuildKubernetesMasterConfig(options configapi.MasterConfig, requestContextM
314304
if err != nil {
315305
glog.Fatalf("Error setting up OAuth2 client certificates: %v", err)
316306
}
307+
requestHeaderCACerts, err := configapi.GetRequestHeaderClientCertCAs(options)
308+
if err != nil {
309+
glog.Fatalf("Error setting up request header client certificates: %v", err)
310+
}
311+
if len(requestHeaderCACerts) > 0 {
312+
genericConfig.SecureServingInfo.ExtraClientCACerts = append(genericConfig.SecureServingInfo.ExtraClientCACerts, requestHeaderCACerts...)
313+
}
314+
317315
url, err := url.Parse(options.MasterPublicURL)
318316
if err != nil {
319317
glog.Fatalf("Error parsing master public url %q: %v", options.MasterPublicURL, err)

0 commit comments

Comments
 (0)