|
4 | 4 | "crypto/tls"
|
5 | 5 | "errors"
|
6 | 6 | "fmt"
|
| 7 | + "io/ioutil" |
7 | 8 | "net"
|
8 | 9 | "net/http"
|
9 | 10 | "net/url"
|
@@ -112,6 +113,17 @@ func BuildDefaultAPIServer(options configapi.MasterConfig) (*apiserveroptions.Se
|
112 | 113 | server.GenericServerRunOptions.TLSCertFile = options.ServingInfo.ServerCert.CertFile
|
113 | 114 | server.GenericServerRunOptions.TLSPrivateKeyFile = options.ServingInfo.ServerCert.KeyFile
|
114 | 115 | server.GenericServerRunOptions.ClientCAFile = options.ServingInfo.ClientCA
|
| 116 | + |
| 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 | + |
115 | 127 | server.GenericServerRunOptions.MaxRequestsInFlight = options.ServingInfo.MaxRequestsInFlight
|
116 | 128 | server.GenericServerRunOptions.MinRequestTimeout = options.ServingInfo.RequestTimeoutSeconds
|
117 | 129 | for _, nc := range options.ServingInfo.NamedCertificates {
|
@@ -542,3 +554,27 @@ func getAPIResourceConfig(options configapi.MasterConfig) genericapiserver.APIRe
|
542 | 554 |
|
543 | 555 | return resourceConfig
|
544 | 556 | }
|
| 557 | + |
| 558 | +// TODO remove this func in 1.6 when we get rid of the hack above |
| 559 | +func concatenateFiles(prefix, separator string, files ...string) (string, error) { |
| 560 | + data := []byte{} |
| 561 | + for _, file := range files { |
| 562 | + fileBytes, err := ioutil.ReadFile(file) |
| 563 | + if err != nil { |
| 564 | + return "", err |
| 565 | + } |
| 566 | + data = append(data, fileBytes...) |
| 567 | + data = append(data, []byte(separator)...) |
| 568 | + } |
| 569 | + tmpFile, err := ioutil.TempFile("", prefix) |
| 570 | + if err != nil { |
| 571 | + return "", err |
| 572 | + } |
| 573 | + if _, err := tmpFile.Write(data); err != nil { |
| 574 | + return "", err |
| 575 | + } |
| 576 | + if err := tmpFile.Close(); err != nil { |
| 577 | + return "", err |
| 578 | + } |
| 579 | + return tmpFile.Name(), nil |
| 580 | +} |
0 commit comments