Explorar el Código

Merge pull request #2750 from smallstep/herman/android-crl

Herman Slatman hace 4 meses
padre
commit
7ee99a5f99
Se han modificado 2 ficheros con 14 adiciones y 7 borrados
  1. 10 3
      authority/provisioner/acme.go
  2. 4 4
      authority/provisioner/acme_test.go

+ 10 - 3
authority/provisioner/acme.go

@@ -149,6 +149,15 @@ type androidCRL struct {
 	fetchedAt time.Time
 }
 
+// contains returns whether or not [*x509.Certificate]'s
+// serial number is in the map of revoked certificate serial
+// numbers. Google encodes these as lowercase hex.
+func (a *androidCRL) contains(cert *x509.Certificate) bool {
+	_, revoked := a.serials[cert.SerialNumber.Text(16)]
+
+	return revoked
+}
+
 // GetID returns the provisioner unique identifier.
 func (p ACME) GetID() string {
 	if p.ID != "" {
@@ -529,7 +538,5 @@ func (p *ACME) IsAndroidCertificateRevoked(ctx context.Context, cert *x509.Certi
 		return true, err
 	}
 
-	_, revoked := crl.serials[cert.SerialNumber.String()]
-
-	return revoked, nil
+	return crl.contains(cert), nil
 }

+ 4 - 4
authority/provisioner/acme_test.go

@@ -488,11 +488,11 @@ func certWithSerial(serial int64) *x509.Certificate {
 }
 
 func TestACME_IsAndroidCertificateRevoked(t *testing.T) {
-	// The CRL reports serial number 42 as revoked. The delay ensures a burst
-	// of concurrent lookups overlaps on the initial fetch so that the
-	// singleflight coalescing is actually exercised.
+	// The CRL reports serial number 42 (hex 2a) as revoked. The delay
+	// ensures a burst of concurrent lookups overlaps on the initial fetch
+	// so that the singleflight coalescing is actually exercised.
 	client := &countingHTTPClient{
-		body:  `{"entries":{"42":{"status":"REVOKED"}}}`,
+		body:  `{"entries":{"2a":{"status":"REVOKED"}}}`,
 		delay: 50 * time.Millisecond,
 	}