Skip to content

Commit

Permalink
tlsconfig: remove deprecated io/ioutil
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Nov 10, 2023
1 parent c564c21 commit 9548f9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
7 changes: 3 additions & 4 deletions tlsconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"encoding/pem"
"errors"
"fmt"
"io/ioutil"
"os"
)

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down
9 changes: 4 additions & 5 deletions tlsconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/tls"
"crypto/x509"
"encoding/pem"
"io/ioutil"
"os"
"reflect"
"runtime"
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 9548f9f

Please sign in to comment.