@@ -10,14 +10,13 @@ import (
1010 "crypto/x509/pkix"
1111 "encoding/asn1"
1212 "encoding/pem"
13- "io/ioutil"
1413 "math"
14+ "os"
1515 "testing"
1616 "time"
1717
18- "golang.org/x/crypto/ocsp"
19-
2018 "github.com/google/certificate-transparency-go"
19+ "golang.org/x/crypto/ocsp"
2120)
2221
2322const (
@@ -52,7 +51,7 @@ const (
5251func TestParseCertificatesDER (t * testing.T ) {
5352 var password = []string {"password" , "" , "" }
5453 for i , testFile := range []string {testPKCS12Passwordispassword , testPKCS12EmptyPswd , testCertDERFile } {
55- testDER , err := ioutil .ReadFile (testFile )
54+ testDER , err := os .ReadFile (testFile )
5655 if err != nil {
5756 t .Fatal (err )
5857 }
@@ -65,7 +64,7 @@ func TestParseCertificatesDER(t *testing.T) {
6564 }
6665 }
6766
68- testDER , err := ioutil .ReadFile (testEmptyPKCS7DER )
67+ testDER , err := os .ReadFile (testEmptyPKCS7DER )
6968 if err != nil {
7069 t .Fatal (err )
7170 }
@@ -89,7 +88,7 @@ func TestKeyLength(t *testing.T) {
8988 t .Fatal ("KeyLength malfunctioning on nonsense input" )
9089 }
9190
92- //test the ecdsa branch
91+ // test the ecdsa branch
9392 ecdsaPriv , _ := ecdsa .GenerateKey (elliptic .P224 (), rand .Reader )
9493 ecdsaIn , _ := ecdsaPriv .Public ().(* ecdsa.PublicKey )
9594 expEcdsa := ecdsaIn .Curve .Params ().BitSize
@@ -98,7 +97,7 @@ func TestKeyLength(t *testing.T) {
9897 t .Fatal ("KeyLength malfunctioning on ecdsa input" )
9998 }
10099
101- //test the rsa branch
100+ // test the rsa branch
102101 rsaPriv , _ := rsa .GenerateKey (rand .Reader , 256 )
103102 rsaIn , _ := rsaPriv .Public ().(* rsa.PublicKey )
104103 expRsa := rsaIn .N .BitLen ()
@@ -118,8 +117,8 @@ func TestExpiryTime(t *testing.T) {
118117 t .Fatal ("Expiry time is malfunctioning on empty input" )
119118 }
120119
121- //read a pem file and use that expiry date
122- bytes , _ := ioutil .ReadFile (testBundleFile )
120+ // read a pem file and use that expiry date
121+ bytes , _ := os .ReadFile (testBundleFile )
123122 certs , err := ParseCertificatesPEM (bytes )
124123 if err != nil {
125124 t .Fatalf ("%v" , err )
@@ -269,7 +268,7 @@ func TestSignatureString(t *testing.T) {
269268
270269func TestParseCertificatePEM (t * testing.T ) {
271270 for _ , testFile := range []string {testCertFile , testExtraWSCertFile , testSinglePKCS7 } {
272- certPEM , err := ioutil .ReadFile (testFile )
271+ certPEM , err := os .ReadFile (testFile )
273272 if err != nil {
274273 t .Fatal (err )
275274 }
@@ -280,7 +279,7 @@ func TestParseCertificatePEM(t *testing.T) {
280279 }
281280 }
282281 for _ , testFile := range []string {testBundleFile , testMessedUpCertFile , testEmptyPKCS7PEM , testEmptyCertFile , testMultiplePKCS7 } {
283- certPEM , err := ioutil .ReadFile (testFile )
282+ certPEM , err := os .ReadFile (testFile )
284283 if err != nil {
285284 t .Fatal (err )
286285 }
@@ -294,7 +293,7 @@ func TestParseCertificatePEM(t *testing.T) {
294293func TestParseCertificatesPEM (t * testing.T ) {
295294 // expected cases
296295 for _ , testFile := range []string {testBundleFile , testExtraWSBundleFile , testSinglePKCS7 , testMultiplePKCS7 } {
297- bundlePEM , err := ioutil .ReadFile (testFile )
296+ bundlePEM , err := os .ReadFile (testFile )
298297 if err != nil {
299298 t .Fatal (err )
300299 }
@@ -308,7 +307,7 @@ func TestParseCertificatesPEM(t *testing.T) {
308307 // test failure cases
309308 // few lines deleted, then headers removed
310309 for _ , testFile := range []string {testMessedUpBundleFile , testEmptyPKCS7PEM , testNoHeaderCert } {
311- bundlePEM , err := ioutil .ReadFile (testFile )
310+ bundlePEM , err := os .ReadFile (testFile )
312311 if err != nil {
313312 t .Fatal (err )
314313 }
@@ -320,7 +319,7 @@ func TestParseCertificatesPEM(t *testing.T) {
320319}
321320
322321func TestSelfSignedCertificatePEM (t * testing.T ) {
323- testPEM , err := ioutil .ReadFile (testCertFile )
322+ testPEM , err := os .ReadFile (testCertFile )
324323 if err != nil {
325324 t .Fatal (err )
326325 }
@@ -330,7 +329,7 @@ func TestSelfSignedCertificatePEM(t *testing.T) {
330329 }
331330
332331 // a few lines deleted from the pem file
333- wrongPEM , err := ioutil .ReadFile (testMessedUpCertFile )
332+ wrongPEM , err := os .ReadFile (testMessedUpCertFile )
334333 if err != nil {
335334 t .Fatal (err )
336335 }
@@ -353,7 +352,7 @@ func TestSelfSignedCertificatePEM(t *testing.T) {
353352func TestParsePrivateKeyPEM (t * testing.T ) {
354353
355354 // expected cases
356- testRSAPEM , err := ioutil .ReadFile (testPrivateRSAKey )
355+ testRSAPEM , err := os .ReadFile (testPrivateRSAKey )
357356 if err != nil {
358357 t .Fatal (err )
359358 }
@@ -362,7 +361,7 @@ func TestParsePrivateKeyPEM(t *testing.T) {
362361 t .Fatal (err )
363362 }
364363
365- testECDSAPEM , err := ioutil .ReadFile (testPrivateECDSAKey )
364+ testECDSAPEM , err := os .ReadFile (testPrivateECDSAKey )
366365 if err != nil {
367366 t .Fatal (err )
368367 }
@@ -371,7 +370,7 @@ func TestParsePrivateKeyPEM(t *testing.T) {
371370 t .Fatal (err )
372371 }
373372
374- testEd25519PEM , err := ioutil .ReadFile (testPrivateEd25519Key )
373+ testEd25519PEM , err := os .ReadFile (testPrivateEd25519Key )
375374 if err != nil {
376375 t .Fatal (err )
377376 }
@@ -381,7 +380,7 @@ func TestParsePrivateKeyPEM(t *testing.T) {
381380 t .Fatal (err )
382381 }
383382
384- testOpenSSLECKey , err := ioutil .ReadFile (testPrivateOpenSSLECKey )
383+ testOpenSSLECKey , err := os .ReadFile (testPrivateOpenSSLECKey )
385384 if err != nil {
386385 t .Fatal (err )
387386 }
@@ -400,7 +399,7 @@ func TestParsePrivateKeyPEM(t *testing.T) {
400399 }
401400
402401 for _ , fname := range errCases {
403- testPEM , _ := ioutil .ReadFile (fname )
402+ testPEM , _ := os .ReadFile (fname )
404403 _ , err = ParsePrivateKeyPEM (testPEM )
405404 if err == nil {
406405 t .Fatal ("Incorrect private key failed to produce an error" )
@@ -413,7 +412,7 @@ func TestParsePrivateKeyPEM(t *testing.T) {
413412const ecdsaTestCSR = "testdata/ecdsa256.csr"
414413
415414func TestParseCSRPEM (t * testing.T ) {
416- in , err := ioutil .ReadFile (ecdsaTestCSR )
415+ in , err := os .ReadFile (ecdsaTestCSR )
417416 if err != nil {
418417 t .Fatalf ("%v" , err )
419418 }
@@ -432,7 +431,7 @@ func TestParseCSRPEM(t *testing.T) {
432431}
433432
434433func TestParseCSRPEMMore (t * testing.T ) {
435- csrPEM , err := ioutil .ReadFile (testCSRPEM )
434+ csrPEM , err := os .ReadFile (testCSRPEM )
436435 if err != nil {
437436 t .Fatal (err )
438437 }
@@ -441,7 +440,7 @@ func TestParseCSRPEMMore(t *testing.T) {
441440 t .Fatal (err )
442441 }
443442
444- csrPEM , err = ioutil .ReadFile (testCSRPEMBad )
443+ csrPEM , err = os .ReadFile (testCSRPEMBad )
445444 if err != nil {
446445 t .Fatal (err )
447446 }
@@ -459,7 +458,7 @@ func TestParseCSRPEMMore(t *testing.T) {
459458const rsaOldTestCSR = "testdata/rsa-old.csr"
460459
461460func TestParseOldCSR (t * testing.T ) {
462- in , err := ioutil .ReadFile (rsaOldTestCSR )
461+ in , err := os .ReadFile (rsaOldTestCSR )
463462 if err != nil {
464463 t .Fatalf ("%v" , err )
465464 }
@@ -508,7 +507,7 @@ func TestLoadPEMCertPool(t *testing.T) {
508507 t .Fatal ("Empty file name should not generate error or a cert pool" )
509508 }
510509
511- in , err := ioutil .ReadFile (testEmptyPem )
510+ in , err := os .ReadFile (testEmptyPem )
512511 if err != nil {
513512 t .Fatalf ("%v" , err )
514513 }
@@ -519,7 +518,7 @@ func TestLoadPEMCertPool(t *testing.T) {
519518 t .Fatal ("Expected error for empty file" )
520519 }
521520
522- in , err = ioutil .ReadFile (testEmptyCertFile )
521+ in , err = os .ReadFile (testEmptyCertFile )
523522 if err != nil {
524523 t .Fatalf ("%v" , err )
525524 }
@@ -530,7 +529,7 @@ func TestLoadPEMCertPool(t *testing.T) {
530529 t .Fatal ("Expected error for empty cert" )
531530 }
532531
533- in , err = ioutil .ReadFile (clientCertFile )
532+ in , err = os .ReadFile (clientCertFile )
534533 if err != nil {
535534 t .Fatalf ("%v" , err )
536535 }
0 commit comments