From 1c7b3c30722b127c8680976a65fb76d5a78cbb3f Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Tue, 15 Sep 2020 13:54:19 -0500 Subject: [PATCH] Fix base64 encoding style in webhookcachefiller. This was previously using the unpadded (raw) base64 encoder, which worked sometimes (if the CA happened to be a length that didn't require padding). The correct encoding is the `base64.StdEncoding` one that includes padding. Signed-off-by: Matt Moyer --- .../identityprovider/webhookcachefiller/webhookcachefiller.go | 2 +- .../webhookcachefiller/webhookcachefiller_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/controller/identityprovider/webhookcachefiller/webhookcachefiller.go b/internal/controller/identityprovider/webhookcachefiller/webhookcachefiller.go index 6b67d940..867ba6dc 100644 --- a/internal/controller/identityprovider/webhookcachefiller/webhookcachefiller.go +++ b/internal/controller/identityprovider/webhookcachefiller/webhookcachefiller.go @@ -123,5 +123,5 @@ func getCABundle(spec *idpv1alpha1.TLSSpec) ([]byte, error) { if spec == nil { return nil, nil } - return base64.RawStdEncoding.DecodeString(spec.CertificateAuthorityData) + return base64.StdEncoding.DecodeString(spec.CertificateAuthorityData) } diff --git a/internal/controller/identityprovider/webhookcachefiller/webhookcachefiller_test.go b/internal/controller/identityprovider/webhookcachefiller/webhookcachefiller_test.go index c2d9fc17..82e4fa35 100644 --- a/internal/controller/identityprovider/webhookcachefiller/webhookcachefiller_test.go +++ b/internal/controller/identityprovider/webhookcachefiller/webhookcachefiller_test.go @@ -159,7 +159,7 @@ func TestNewWebhookAuthenticator(t *testing.T) { spec := &idpv1alpha1.WebhookIdentityProviderSpec{ Endpoint: url, TLS: &idpv1alpha1.TLSSpec{ - CertificateAuthorityData: base64.RawStdEncoding.EncodeToString([]byte(caBundle)), + CertificateAuthorityData: base64.StdEncoding.EncodeToString([]byte(caBundle)), }, } res, err := newWebhookAuthenticator(spec, ioutil.TempFile, clientcmd.WriteToFile)