From e89dcf77837168a4f806d1a9813e033613088029 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Thu, 17 Jun 2021 19:05:21 -0400 Subject: [PATCH] tlsutil: Un-method Configurator.check The method receiver was never used. Also rename it and add a godoc comment. --- tlsutil/config.go | 8 +++++--- tlsutil/config_test.go | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tlsutil/config.go b/tlsutil/config.go index 1a26f7113..d72d0397c 100644 --- a/tlsutil/config.go +++ b/tlsutil/config.go @@ -245,7 +245,7 @@ func (c *Configurator) Update(config Config) error { if err != nil { return err } - if err = c.check(config, pool, cert); err != nil { + if err = validateConfig(config, pool, cert); err != nil { return err } c.base = &config @@ -270,7 +270,7 @@ func (c *Configurator) UpdateAutoTLSCA(connectCAPems []string) error { if err != nil { return err } - if err = c.check(*c.base, pool, c.manual.cert); err != nil { + if err = validateConfig(*c.base, pool, c.manual.cert); err != nil { return err } c.autoTLS.connectCAPems = connectCAPems @@ -357,7 +357,9 @@ func pool(pems []string) (*x509.CertPool, error) { return pool, nil } -func (c *Configurator) check(config Config, pool *x509.CertPool, cert *tls.Certificate) error { +// validateConfig checks that config is valid and does not conflict with the pool +// or cert. +func validateConfig(config Config, pool *x509.CertPool, cert *tls.Certificate) error { // Check if a minimum TLS version was set if config.TLSMinVersion != "" { if _, ok := TLSLookup[config.TLSMinVersion]; !ok { diff --git a/tlsutil/config_test.go b/tlsutil/config_test.go index 571ff8113..2608d2803 100644 --- a/tlsutil/config_test.go +++ b/tlsutil/config_test.go @@ -524,7 +524,7 @@ func TestConfigurator_ErrorPropagation(t *testing.T) { require.NoError(t, err, info) pool, err := pool(pems) require.NoError(t, err, info) - err3 = c.check(v.config, pool, cert) + err3 = validateConfig(v.config, pool, cert) } if v.shouldErr { require.Error(t, err1, info)