Don't re-deserialize cert in GeneratePurgeURLs (#5157)

The only caller of this function is the RA's `revokeCertificate`
method, which already has the hydrated `x509.Certificate`
version of the cert. There's no need to pass the raw version
and re-parse the DER again, just pass a reference to the
existing cert.
This commit is contained in:
Aaron Gable 2020-10-29 16:13:50 -07:00 committed by GitHub
parent 67cae0c8fa
commit 0f015b0034
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -357,13 +357,11 @@ func generateOCSPCacheKeys(req []byte, ocspServer string) []string {
}
}
// GeneratePurgeURLs ...
func GeneratePurgeURLs(der []byte, issuer *x509.Certificate) ([]string, error) {
cert, err := x509.ParseCertificate(der)
if err != nil {
return nil, err
}
// GeneratePurgeURLs generates akamai URLs that can be POSTed to in order to
// purge akamai's cache of the corresponding OCSP responses. The URLs encode
// the contents of the OCSP request, so this method constructs a full OCSP
// request.
func GeneratePurgeURLs(cert, issuer *x509.Certificate) ([]string, error) {
req, err := ocsp.CreateRequest(cert, issuer, nil)
if err != nil {
return nil, err

View File

@ -1711,7 +1711,7 @@ func (ra *RegistrationAuthorityImpl) revokeCertificate(ctx context.Context, cert
return err
}
}
purgeURLs, err := akamai.GeneratePurgeURLs(cert.Raw, ra.issuer.Certificate)
purgeURLs, err := akamai.GeneratePurgeURLs(&cert, ra.issuer.Certificate)
if err != nil {
return err
}