Skip to content

Commit

Permalink
Fix expired unit test certs
Browse files Browse the repository at this point in the history
  • Loading branch information
liggitt committed May 23, 2021
1 parent 1259f13 commit 629f7b2
Show file tree
Hide file tree
Showing 17 changed files with 155 additions and 189 deletions.
1 change: 1 addition & 0 deletions staging/src/k8s.io/kube-aggregator/pkg/apiserver/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ go_test(
"handler_apis_test.go",
"handler_proxy_test.go",
],
data = glob(["testdata/**"]),
embed = [":go_default_library"],
deps = [
"//staging/src/k8s.io/apimachinery/pkg/api/equality:go_default_library",
Expand Down
215 changes: 26 additions & 189 deletions staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,15 @@ func TestGetContextForNewRequest(t *testing.T) {
// instead it manually calls to updateAPIService and RunOnce to reload the certificate
func TestProxyCertReload(t *testing.T) {
// STEP 1: set up a backend server that will require the client certificate
// this server uses clientCaCrt to validate the client certificate
// this server uses clientCaCrt() to validate the client certificate
backendHandler := &targetHTTPHandler{}
backendServer := httptest.NewUnstartedServer(backendHandler)
if cert, err := tls.X509KeyPair(backendCertificate, backendKey); err != nil {
if cert, err := tls.X509KeyPair(backendCertificate(), backendKey()); err != nil {
t.Fatal(err)
} else {
caCertPool := x509.NewCertPool()
// we're testing this while enabling MTLS
caCertPool.AppendCertsFromPEM(clientCaCrt)
caCertPool.AppendCertsFromPEM(clientCaCrt())
backendServer.TLS = &tls.Config{Certificates: []tls.Certificate{cert}, ClientAuth: tls.RequireAndVerifyClientCert, ClientCAs: caCertPool}
}
backendServer.StartTLS()
Expand All @@ -606,7 +606,7 @@ func TestProxyCertReload(t *testing.T) {
serviceResolver: &mockedRouter{destinationHost: backendServer.Listener.Addr().String()},
}
certFile, keyFile, dir := getCertAndKeyPaths(t)
writeCerts(certFile, keyFile, backendCertificate, backendKey, t)
writeCerts(certFile, keyFile, backendCertificate(), backendKey(), t)

defer func() {
if err := os.RemoveAll(dir); err != nil {
Expand All @@ -630,7 +630,7 @@ func TestProxyCertReload(t *testing.T) {
Service: &apiregistration.ServiceReference{Name: "test-service2", Namespace: "test-ns", Port: pointer.Int32Ptr(443)},
Group: "foo",
Version: "v1",
CABundle: backendCaCertificate, // used to validate backendCertificate
CABundle: backendCaCertificate(), // used to validate backendCertificate()
},
Status: apiregistration.APIServiceStatus{
Conditions: []apiregistration.APIServiceCondition{
Expand All @@ -655,8 +655,8 @@ func TestProxyCertReload(t *testing.T) {
}

// STEP 3: swap the certificate used by the aggregator to auth against the backend server and verify the request passes
// note that this step uses the certificate that can be validated by the backend server with clientCaCrt
writeCerts(certFile, keyFile, clientCert, clientKey, t)
// note that this step uses the certificate that can be validated by the backend server with clientCaCrt()
writeCerts(certFile, keyFile, clientCert(), clientKey(), t)
err = certProvider.RunOnce()
if err != nil {
t.Fatalf("Expected no error when refreshing dynamic certs, got %v", err)
Expand Down Expand Up @@ -691,186 +691,23 @@ func writeCerts(certFile, keyFile string, certContent, keyContent []byte, t *tes
}
}

func readTestFile(filename string) []byte {
data, err := ioutil.ReadFile("testdata/" + filename)
if err != nil {
panic(err)
}
return data
}

// cert and ca for client auth
var clientCert = []byte(`-----BEGIN CERTIFICATE-----
MIIFaDCCA1ACAWUwDQYJKoZIhvcNAQEFBQAwejELMAkGA1UEBhMCVVMxEzARBgNV
BAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxGDAWBgNVBAoM
D015IG9yZ2FuaXphdGlvbjEQMA4GA1UECwwHTXkgdW5pdDESMBAGA1UEAwwJbG9j
YWxob3N0MB4XDTIwMDUyMjA4MTA1MVoXDTIxMDUyMjA4MTA1MVowejELMAkGA1UE
BhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDU1vdW50YWluIFZp
ZXcxGDAWBgNVBAoMD015IG9yZ2FuaXphdGlvbjEQMA4GA1UECwwHTXkgdW5pdDES
MBAGA1UEAwwJ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NKHP63f+bHp8hhK
4ulSKQ==
-----END CERTIFICATE-----`)
func clientCert() []byte { return readTestFile("client.pem") }

func clientKey() []byte { return readTestFile("client-key.pem") }

func backendCertificate() []byte { return readTestFile("server.pem") }

func backendKey() []byte { return readTestFile("server-key.pem") }

func backendCaCertificate() []byte { return readTestFile("server-ca.pem") }

func clientCaCrt() []byte { return readTestFile("client-ca.pem") }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Keys in this directory are generated for testing purposes only.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIHM3EPGDat3kZv4DmyI6X0k6gHGP9JSS3R9t0sCvcj1coAoGCCqGSM49
AwEHoUQDQgAEA4QqivypLZVLaoFYAS0UWyfyNRSXRtgMWEabvsoHO31CRa2ZS3m8
glOQ21aLysVdF6vAP31O9fqysuGMm0UI7w==
-----END EC PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----BEGIN CERTIFICATE-----
MIIBbTCCARSgAwIBAgIUDMmq4/Gw2N1o5TWBLWsm65RiVkIwCgYIKoZIzj0EAwIw
FDESMBAGA1UEAxMJQ2xpZW50LUNBMCAXDTIxMDUyMjIzNTIwMFoYDzIxMjEwNDI4
MjM1MjAwWjAUMRIwEAYDVQQDEwlDbGllbnQtQ0EwWTATBgcqhkjOPQIBBggqhkjO
PQMBBwNCAAQDhCqK/KktlUtqgVgBLRRbJ/I1FJdG2AxYRpu+ygc7fUJFrZlLebyC
U5DbVovKxV0Xq8A/fU71+rKy4YybRQjvo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUaDl2pG6N7NoORQjpHprKDSOL8+0wCgYI
KoZIzj0EAwIDRwAwRAIgbS1tdj6El37kUwF9yZDXKfjLUlRBBLmIYhP0mdui6/AC
IB4F/weuM/6IjCdcPJRxvdC7qjCdV0xnFqvQ+BhuUGSF
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIJVbghSTWVClgCMEMWHf4Z5QRHplGl3OZzNvvYVc1hVLoAoGCCqGSM49
AwEHoUQDQgAEI7HyyXMDVAU8o3kQpInG+Ec1mCELWJrKz2owv0jONgc7dkDjKHuP
7UkDuKGrUpS2MW0UkqajJAODEUwSF1wH5A==
-----END EC PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----BEGIN CERTIFICATE-----
MIIBoTCCAUegAwIBAgIUci8u0GG5LGSaykYqdgYL9ZIO/v4wCgYIKoZIzj0EAwIw
FDESMBAGA1UEAxMJQ2xpZW50LUNBMCAXDTIxMDUyMjIzNTIwMFoYDzIxMjEwNDI4
MjM1MjAwWjAUMRIwEAYDVQQDEwlNeSBDbGllbnQwWTATBgcqhkjOPQIBBggqhkjO
PQMBBwNCAAQjsfLJcwNUBTyjeRCkicb4RzWYIQtYmsrPajC/SM42Bzt2QOMoe4/t
SQO4oatSlLYxbRSSpqMkA4MRTBIXXAfko3UwczAOBgNVHQ8BAf8EBAMCBaAwEwYD
VR0lBAwwCgYIKwYBBQUHAwIwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUaS3acr6g
cfHE/zty3M0nd9aDo30wHwYDVR0jBBgwFoAUaDl2pG6N7NoORQjpHprKDSOL8+0w
CgYIKoZIzj0EAwIDSAAwRQIhAPjuVM2rWOhyzfRqAAdn8a/LJxjLf1+bjrb/cyT4
h0LbAiBE8MY0gARwVYoRgYmVMXyewwjW+SVu+y8+kQv7uCFJzg==
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"CN": "Client-CA",
"ca": {
"expiry": "876000h"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CN": "My Client"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"signing": {
"profiles": {
"client": {
"expiry": "876000h",
"usages": [
"signing",
"key encipherment",
"client auth"
]
},
"server": {
"expiry": "876000h",
"usages": [
"signing",
"key encipherment",
"server auth"
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"CN": "Server-CA",
"ca": {
"expiry": "876000h"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"CN": "test-service2.test-ns.svc",
"hosts": ["test-service2.test-ns.svc"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Copyright 2021 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cfssl gencert -initca generate.client-ca.json | cfssljson -bare client-ca
cfssl gencert -initca generate.server-ca.json | cfssljson -bare server-ca

cfssl gencert -ca client-ca.pem -ca-key client-ca-key.pem -config generate.profiles.json --profile=client generate.client.json | cfssljson -bare client
cfssl gencert -ca server-ca.pem -ca-key server-ca-key.pem -config generate.profiles.json --profile=server generate.server.json | cfssljson -bare server

rm ./*.csr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIBoMWQC4K4Vp/wKA7yHBVWgjV69lpGhAZZAAcsf8osUVoAoGCCqGSM49
AwEHoUQDQgAEPwxv8IjkfU5AivcK0IiurHL9H6EiGh+zZ0S8r+PBW0DXFPXcAjQc
tE8gVHu3fp90y1JVTriaxriU/x8Lbrp8ZA==
-----END EC PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----BEGIN CERTIFICATE-----
MIIBbzCCARSgAwIBAgIUf0aG2C1P7KaDGobg9oeN3uhQlu4wCgYIKoZIzj0EAwIw
FDESMBAGA1UEAxMJU2VydmVyLUNBMCAXDTIxMDUyMjIzNTIwMFoYDzIxMjEwNDI4
MjM1MjAwWjAUMRIwEAYDVQQDEwlTZXJ2ZXItQ0EwWTATBgcqhkjOPQIBBggqhkjO
PQMBBwNCAAQ/DG/wiOR9TkCK9wrQiK6scv0foSIaH7NnRLyv48FbQNcU9dwCNBy0
TyBUe7d+n3TLUlVOuJrGuJT/Hwtuunxko0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUjcdIlU1vGLSUWBcSqCEJTgqlSacwCgYI
KoZIzj0EAwIDSQAwRgIhAIujFeJKprddp+9aCZZUv05jCS5JiopW2bn/FJJRQ6OK
AiEA1NS6trAbfgk6vYS2D2vamuF4XC9LggyxbcoaMf+GAn4=
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIFizWdUWI/ggduZByisCOjPljfUq/f++RwQl0scxeOU/oAoGCCqGSM49
AwEHoUQDQgAEvw23SM/msE+rsXx919gkNM+A7HBJ99YXqvsV0zRd6ykiQV5rszGw
DHF/3sKTbb38eLcF/sORWVEFc4+QqnZLkw==
-----END EC PRIVATE KEY-----
Loading

0 comments on commit 629f7b2

Please sign in to comment.