diff --git a/tlsconfig/config.go b/tlsconfig/config.go index f4c4b602..606c98a3 100644 --- a/tlsconfig/config.go +++ b/tlsconfig/config.go @@ -12,7 +12,6 @@ import ( "encoding/pem" "errors" "fmt" - "io/ioutil" "os" ) @@ -104,7 +103,7 @@ func certPool(caFile string, exclusivePool bool) (*x509.CertPool, error) { return nil, fmt.Errorf("failed to read system certificates: %v", err) } } - pemData, err := ioutil.ReadFile(caFile) + pemData, err := os.ReadFile(caFile) if err != nil { return nil, fmt.Errorf("could not read CA certificate %q: %v", caFile, err) } @@ -186,12 +185,12 @@ func getCert(options Options) ([]tls.Certificate, error) { return nil, nil } - cert, err := ioutil.ReadFile(options.CertFile) + cert, err := os.ReadFile(options.CertFile) if err != nil { return nil, err } - prKeyBytes, err := ioutil.ReadFile(options.KeyFile) + prKeyBytes, err := os.ReadFile(options.KeyFile) if err != nil { return nil, err } diff --git a/tlsconfig/config_test.go b/tlsconfig/config_test.go index e18473c5..11b607dd 100644 --- a/tlsconfig/config_test.go +++ b/tlsconfig/config_test.go @@ -5,7 +5,6 @@ import ( "crypto/tls" "crypto/x509" "encoding/pem" - "io/ioutil" "os" "reflect" "runtime" @@ -69,7 +68,7 @@ func TestConfigServerTLSFailsIfUnableToLoadCerts(t *testing.T) { key, cert := getCertAndKey() ca := getMultiCert() - tempFile, err := ioutil.TempFile("", "cert-test") + tempFile, err := os.CreateTemp("", "cert-test") if err != nil { t.Fatal("Unable to create temporary empty file") } @@ -206,7 +205,7 @@ func TestConfigServerExclusiveRootPools(t *testing.T) { key, cert := getCertAndKey() ca := getMultiCert() - caBytes, err := ioutil.ReadFile(ca) + caBytes, err := os.ReadFile(ca) if err != nil { t.Fatal("Unable to read CA certs", err) } @@ -471,7 +470,7 @@ func TestConfigClientTLSNonexistentRootCAFile(t *testing.T) { func TestConfigClientTLSClientCertOrKeyInvalid(t *testing.T) { key, cert := getCertAndKey() - tempFile, err := ioutil.TempFile("", "cert-test") + tempFile, err := os.CreateTemp("", "cert-test") if err != nil { t.Fatal("Unable to create temporary empty file") } @@ -569,7 +568,7 @@ func TestConfigClientExclusiveRootPools(t *testing.T) { } ca := getMultiCert() - caBytes, err := ioutil.ReadFile(ca) + caBytes, err := os.ReadFile(ca) if err != nil { t.Fatal("Unable to read CA certs", err) }