diff --git a/ocsp/ocsp.go b/ocsp/ocsp.go index 4beab24bc..718b2ca9c 100644 --- a/ocsp/ocsp.go +++ b/ocsp/ocsp.go @@ -1,9 +1,7 @@ /* - Package ocsp exposes OCSP signing functionality, much like the signer package does for certificate signing. It also provies a basic OCSP responder stack for serving pre-signed OCSP responses. - */ package ocsp @@ -12,7 +10,7 @@ import ( "crypto" "crypto/x509" "crypto/x509/pkix" - "io/ioutil" + "os" "strconv" "strings" "time" @@ -113,12 +111,12 @@ func NewSignerFromFile(issuerFile, responderFile, keyFile string, interval time. return nil, err } log.Debug("Loading responder cert: ", responderFile) - responderBytes, err := ioutil.ReadFile(responderFile) + responderBytes, err := os.ReadFile(responderFile) if err != nil { return nil, err } log.Debug("Loading responder key: ", keyFile) - keyBytes, err := ioutil.ReadFile(keyFile) + keyBytes, err := os.ReadFile(keyFile) if err != nil { return nil, cferr.Wrap(cferr.CertificateError, cferr.ReadFailed, err) } diff --git a/ocsp/ocsp_test.go b/ocsp/ocsp_test.go index 95c8edb5f..1771176f3 100644 --- a/ocsp/ocsp_test.go +++ b/ocsp/ocsp_test.go @@ -1,13 +1,13 @@ package ocsp import ( - "io/ioutil" + "os" "testing" "time" - "golang.org/x/crypto/ocsp" - "github.com/cloudflare/cfssl/helpers" + + "golang.org/x/crypto/ocsp" ) const ( @@ -65,7 +65,7 @@ func TestNewSignerFromFile(t *testing.T) { func setup(t *testing.T) (SignRequest, time.Duration) { dur, _ := time.ParseDuration("1ms") - certPEM, err := ioutil.ReadFile(otherCertFile) + certPEM, err := os.ReadFile(otherCertFile) if err != nil { t.Fatal(err) } diff --git a/ocsp/responder.go b/ocsp/responder.go index 4b90c8bbc..d19a632c2 100644 --- a/ocsp/responder.go +++ b/ocsp/responder.go @@ -15,9 +15,10 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" + "os" "regexp" "time" @@ -131,7 +132,7 @@ func (src DBSource) Response(req *ocsp.Request) ([]byte, http.Header, error) { // PEM without headers or whitespace). Invalid responses are ignored. // This function pulls the entire file into an InMemorySource. func NewSourceFromFile(responseFile string) (Source, error) { - fileContents, err := ioutil.ReadFile(responseFile) + fileContents, err := os.ReadFile(responseFile) if err != nil { return nil, err } @@ -309,7 +310,7 @@ func (rs Responder) ServeHTTP(response http.ResponseWriter, request *http.Reques return } case "POST": - requestBody, err = ioutil.ReadAll(request.Body) + requestBody, err = io.ReadAll(request.Body) if err != nil { log.Errorf("Problem reading body of POST: %s", err) response.WriteHeader(http.StatusBadRequest) diff --git a/ocsp/responder_test.go b/ocsp/responder_test.go index 09990c23d..68cfae341 100644 --- a/ocsp/responder_test.go +++ b/ocsp/responder_test.go @@ -2,10 +2,10 @@ package ocsp import ( "encoding/hex" - "io/ioutil" "net/http" "net/http/httptest" "net/url" + "os" "reflect" "testing" "time" @@ -210,11 +210,11 @@ func TestSqliteTrivial(t *testing.T) { // an OCSP request. certFile := "testdata/sqlite_ca.pem" issuerFile := "testdata/ca.pem" - certContent, err := ioutil.ReadFile(certFile) + certContent, err := os.ReadFile(certFile) if err != nil { t.Errorf("Error reading cert file: %s", err) } - issuerContent, err := ioutil.ReadFile(issuerFile) + issuerContent, err := os.ReadFile(issuerFile) if err != nil { t.Errorf("Error reading issuer file: %s", err) } @@ -274,11 +274,11 @@ func TestSqliteRealResponse(t *testing.T) { certFile := "testdata/cert.pem" issuerFile := "testdata/ca.pem" - certContent, err := ioutil.ReadFile(certFile) + certContent, err := os.ReadFile(certFile) if err != nil { t.Errorf("Error reading cert file: %s", err) } - issuerContent, err := ioutil.ReadFile(issuerFile) + issuerContent, err := os.ReadFile(issuerFile) if err != nil { t.Errorf("Error reading issuer file: %s", err) } @@ -308,7 +308,7 @@ func TestSqliteRealResponse(t *testing.T) { ThisUpdate: time.Now(), NextUpdate: time.Now().AddDate(0, 1, 0), } - keyPEM, err := ioutil.ReadFile("testdata/ca-key.pem") + keyPEM, err := os.ReadFile("testdata/ca-key.pem") if err != nil { t.Errorf("Error reading private key file: %s", err) }