@@ -75,22 +75,18 @@ type RevocationConfig struct {
7575 CRLProvider CRLProvider
7676}
7777
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
8080
8181const (
8282 // RevocationUndetermined means we couldn't find or verify a CRL for the cert.
83- RevocationUndetermined RevocationStatus = iota
83+ RevocationUndetermined revocationStatus = iota
8484 // RevocationUnrevoked means we found the CRL for the cert and the cert is not revoked.
8585 RevocationUnrevoked
8686 // RevocationRevoked means we found the CRL and the cert is revoked.
8787 RevocationRevoked
8888)
8989
90- func (s RevocationStatus ) String () string {
91- return [... ]string {"RevocationUndetermined" , "RevocationUnrevoked" , "RevocationRevoked" }[s ]
92- }
93-
9490// CRL contains a pkix.CertificateList and parsed extensions that aren't
9591// provided by the golang CRL parser.
9692// All CRLs should be loaded using NewCRL() for bytes directly or ReadCRLFile()
@@ -192,25 +188,25 @@ func x509NameHash(r pkix.RDNSequence) string {
192188 return fmt .Sprintf ("%08x" , fileHash )
193189}
194190
195- // CheckRevocation checks the connection for revoked certificates based on RFC5280.
191+ // checkRevocation checks the connection for revoked certificates based on RFC5280.
196192// This implementation has the following major limitations:
197193// - Indirect CRL files are not supported.
198194// - CRL loading is only supported from directories in the X509_LOOKUP_hash_dir format.
199195// - OnlySomeReasons is not supported.
200196// - Delta CRL files are not supported.
201197// - Certificate CRLDistributionPoint must be URLs, but are then ignored and converted into a file path.
202198// - 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 )
205201}
206202
207- // CheckChainRevocation checks the verified certificate chain
203+ // checkChainRevocation checks the verified certificate chain
208204// for revoked certificates based on RFC5280.
209- func CheckChainRevocation (verifiedChains [][]* x509.Certificate , cfg RevocationConfig ) error {
205+ func checkChainRevocation (verifiedChains [][]* x509.Certificate , cfg RevocationConfig ) error {
210206 // Iterate the verified chains looking for one that is RevocationUnrevoked.
211207 // A single RevocationUnrevoked chain is enough to allow the connection, and a single RevocationRevoked
212208 // chain does not mean the connection should fail.
213- count := make (map [RevocationStatus ]int )
209+ count := make (map [revocationStatus ]int )
214210 for _ , chain := range verifiedChains {
215211 switch checkChain (chain , cfg ) {
216212 case RevocationUnrevoked :
@@ -236,7 +232,7 @@ func CheckChainRevocation(verifiedChains [][]*x509.Certificate, cfg RevocationCo
236232// 1. If any certificate is RevocationRevoked, return RevocationRevoked.
237233// 2. If any certificate is RevocationUndetermined, return RevocationUndetermined.
238234// 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 {
240236 chainStatus := RevocationUnrevoked
241237 for _ , c := range chain {
242238 switch checkCert (c , chain , cfg ) {
@@ -318,7 +314,7 @@ func fetchCRL(c *x509.Certificate, crlVerifyCrt []*x509.Certificate, cfg Revocat
318314// RevocationUndetermined.
319315// c is the certificate to check.
320316// 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 {
322318 crl , err := fetchCRL (c , crlVerifyCrt , cfg )
323319 if err != nil {
324320 // 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
343339 return revocation
344340}
345341
346- func checkCertRevocation (c * x509.Certificate , crl * CRL ) (RevocationStatus , error ) {
342+ func checkCertRevocation (c * x509.Certificate , crl * CRL ) (revocationStatus , error ) {
347343 // Per section 5.3.3 we prime the certificate issuer with the CRL issuer.
348344 // Subsequent entries use the previous entry's issuer.
349345 rawEntryIssuer := crl .rawIssuer
0 commit comments