@@ -75,22 +75,18 @@ type RevocationConfig struct {
75
75
CRLProvider CRLProvider
76
76
}
77
77
78
- // RevocationStatus is the revocation status for a certificate or chain.
79
- type RevocationStatus int
78
+ // revocationStatus is the revocation status for a certificate or chain.
79
+ type revocationStatus int
80
80
81
81
const (
82
82
// RevocationUndetermined means we couldn't find or verify a CRL for the cert.
83
- RevocationUndetermined RevocationStatus = iota
83
+ RevocationUndetermined revocationStatus = iota
84
84
// RevocationUnrevoked means we found the CRL for the cert and the cert is not revoked.
85
85
RevocationUnrevoked
86
86
// RevocationRevoked means we found the CRL and the cert is revoked.
87
87
RevocationRevoked
88
88
)
89
89
90
- func (s RevocationStatus ) String () string {
91
- return [... ]string {"RevocationUndetermined" , "RevocationUnrevoked" , "RevocationRevoked" }[s ]
92
- }
93
-
94
90
// CRL contains a pkix.CertificateList and parsed extensions that aren't
95
91
// provided by the golang CRL parser.
96
92
// All CRLs should be loaded using NewCRL() for bytes directly or ReadCRLFile()
@@ -192,25 +188,25 @@ func x509NameHash(r pkix.RDNSequence) string {
192
188
return fmt .Sprintf ("%08x" , fileHash )
193
189
}
194
190
195
- // CheckRevocation checks the connection for revoked certificates based on RFC5280.
191
+ // checkRevocation checks the connection for revoked certificates based on RFC5280.
196
192
// This implementation has the following major limitations:
197
193
// - Indirect CRL files are not supported.
198
194
// - CRL loading is only supported from directories in the X509_LOOKUP_hash_dir format.
199
195
// - OnlySomeReasons is not supported.
200
196
// - Delta CRL files are not supported.
201
197
// - Certificate CRLDistributionPoint must be URLs, but are then ignored and converted into a file path.
202
198
// - CRL checks are done after path building, which goes against RFC4158.
203
- func CheckRevocation (conn tls.ConnectionState , cfg RevocationConfig ) error {
204
- return CheckChainRevocation (conn .VerifiedChains , cfg )
199
+ func checkRevocation (conn tls.ConnectionState , cfg RevocationConfig ) error {
200
+ return checkChainRevocation (conn .VerifiedChains , cfg )
205
201
}
206
202
207
- // CheckChainRevocation checks the verified certificate chain
203
+ // checkChainRevocation checks the verified certificate chain
208
204
// for revoked certificates based on RFC5280.
209
- func CheckChainRevocation (verifiedChains [][]* x509.Certificate , cfg RevocationConfig ) error {
205
+ func checkChainRevocation (verifiedChains [][]* x509.Certificate , cfg RevocationConfig ) error {
210
206
// Iterate the verified chains looking for one that is RevocationUnrevoked.
211
207
// A single RevocationUnrevoked chain is enough to allow the connection, and a single RevocationRevoked
212
208
// chain does not mean the connection should fail.
213
- count := make (map [RevocationStatus ]int )
209
+ count := make (map [revocationStatus ]int )
214
210
for _ , chain := range verifiedChains {
215
211
switch checkChain (chain , cfg ) {
216
212
case RevocationUnrevoked :
@@ -236,7 +232,7 @@ func CheckChainRevocation(verifiedChains [][]*x509.Certificate, cfg RevocationCo
236
232
// 1. If any certificate is RevocationRevoked, return RevocationRevoked.
237
233
// 2. If any certificate is RevocationUndetermined, return RevocationUndetermined.
238
234
// 3. If all certificates are RevocationUnrevoked, return RevocationUnrevoked.
239
- func checkChain (chain []* x509.Certificate , cfg RevocationConfig ) RevocationStatus {
235
+ func checkChain (chain []* x509.Certificate , cfg RevocationConfig ) revocationStatus {
240
236
chainStatus := RevocationUnrevoked
241
237
for _ , c := range chain {
242
238
switch checkCert (c , chain , cfg ) {
@@ -318,7 +314,7 @@ func fetchCRL(c *x509.Certificate, crlVerifyCrt []*x509.Certificate, cfg Revocat
318
314
// RevocationUndetermined.
319
315
// c is the certificate to check.
320
316
// crlVerifyCrt is the group of possible certificates to verify the crl.
321
- func checkCert (c * x509.Certificate , crlVerifyCrt []* x509.Certificate , cfg RevocationConfig ) RevocationStatus {
317
+ func checkCert (c * x509.Certificate , crlVerifyCrt []* x509.Certificate , cfg RevocationConfig ) revocationStatus {
322
318
crl , err := fetchCRL (c , crlVerifyCrt , cfg )
323
319
if err != nil {
324
320
// We couldn't load any valid CRL files for the certificate, so we don't
@@ -343,7 +339,7 @@ func checkCert(c *x509.Certificate, crlVerifyCrt []*x509.Certificate, cfg Revoca
343
339
return revocation
344
340
}
345
341
346
- func checkCertRevocation (c * x509.Certificate , crl * CRL ) (RevocationStatus , error ) {
342
+ func checkCertRevocation (c * x509.Certificate , crl * CRL ) (revocationStatus , error ) {
347
343
// Per section 5.3.3 we prime the certificate issuer with the CRL issuer.
348
344
// Subsequent entries use the previous entry's issuer.
349
345
rawEntryIssuer := crl .rawIssuer
0 commit comments