@@ -74,26 +74,28 @@ func Test_generateCACert(t *testing.T) {
74
74
block , _ := pem .Decode (serverCert .Bytes ())
75
75
if block == nil {
76
76
require .FailNow (t , "failed to decode PEM block containing cert" )
77
- }
78
- if block .Type == "CERTIFICATE" {
79
- cert , err := x509 .ParseCertificate (block .Bytes )
80
- require .NoError (t , err , "failed to parse certificate" )
81
- for _ , h := range tc .hosts {
82
- if err = cert .VerifyHostname (h ); err != nil {
83
- require .EqualValues (t , tc .expectedErr , err .Error (), "certificate verification failed" )
84
- } else if len (tc .hosts ) < 2 && err == nil && tc .expectedErr != "" {
85
- require .EqualValues (t , tc .expectedErr , nil , "expected an error but certification verification succeeded" )
77
+ } else {
78
+ if block .Type == "CERTIFICATE" {
79
+ cert , err := x509 .ParseCertificate (block .Bytes )
80
+ require .NoError (t , err , "failed to parse certificate" )
81
+ for _ , h := range tc .hosts {
82
+ if err = cert .VerifyHostname (h ); err != nil {
83
+ require .EqualValues (t , tc .expectedErr , err .Error (), "certificate verification failed" )
84
+ } else if len (tc .hosts ) < 2 && err == nil && tc .expectedErr != "" {
85
+ require .EqualValues (t , tc .expectedErr , err , "expected an error but certification verification succeeded" )
86
+ }
86
87
}
87
88
}
88
89
}
89
90
// Test that the server key is decodable and parseable.
90
91
block , _ = pem .Decode (serverKey .Bytes ())
91
92
if block == nil {
92
93
require .FailNow (t , "failed to decode PEM block containing public key" )
93
- }
94
- if block .Type == "RSA PRIVATE KEY" {
95
- _ , err := x509 .ParsePKCS1PrivateKey (block .Bytes )
96
- require .NoError (t , err , "failed to parse key" )
94
+ } else {
95
+ if block .Type == "RSA PRIVATE KEY" {
96
+ _ , err := x509 .ParsePKCS1PrivateKey (block .Bytes )
97
+ require .NoError (t , err , "failed to parse key" )
98
+ }
97
99
}
98
100
})
99
101
}
0 commit comments