Skip to content

Commit

Permalink
Cleanup issuePrecertificateInner (#4689)
Browse files Browse the repository at this point in the history
Removes an unnecessary issuePrecertificateInner argument that was always the same thing.
  • Loading branch information
rolandshoemaker authored Feb 27, 2020
1 parent e78ef81 commit 4184dc3
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions ca/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func (ca *CertificateAuthorityImpl) IssuePrecertificate(ctx context.Context, iss
return nil, err
}

precertDER, err := ca.issuePrecertificateInner(ctx, issueReq, serialBigInt, validity, precertType)
precertDER, err := ca.issuePrecertificateInner(ctx, issueReq, serialBigInt, validity)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -665,7 +665,7 @@ func (ca *CertificateAuthorityImpl) generateSerialNumberAndValidity() (*big.Int,
return serialBigInt, validity, nil
}

func (ca *CertificateAuthorityImpl) issuePrecertificateInner(ctx context.Context, issueReq *caPB.IssueCertificateRequest, serialBigInt *big.Int, validity validity, certType certificateType) ([]byte, error) {
func (ca *CertificateAuthorityImpl) issuePrecertificateInner(ctx context.Context, issueReq *caPB.IssueCertificateRequest, serialBigInt *big.Int, validity validity) ([]byte, error) {
csr, err := x509.ParseCertificateRequest(issueReq.Csr)
if err != nil {
return nil, err
Expand Down Expand Up @@ -724,14 +724,11 @@ func (ca *CertificateAuthorityImpl) issuePrecertificateInner(ctx context.Context
Subject: &signer.Subject{
CN: csr.Subject.CommonName,
},
Serial: serialBigInt,
Extensions: extensions,
NotBefore: validity.NotBefore,
NotAfter: validity.NotAfter,
}

if certType == precertType {
req.ReturnPrecert = true
Serial: serialBigInt,
Extensions: extensions,
NotBefore: validity.NotBefore,
NotAfter: validity.NotAfter,
ReturnPrecert: true,
}

serialHex := core.SerialToString(serialBigInt)
Expand Down Expand Up @@ -762,7 +759,7 @@ func (ca *CertificateAuthorityImpl) issuePrecertificateInner(ctx context.Context
ca.log.AuditErrf("Signing failed: serial=[%s] err=[%v]", serialHex, err)
return nil, err
}
ca.signatureCount.With(prometheus.Labels{"purpose": string(certType)}).Inc()
ca.signatureCount.WithLabelValues(string(precertType)).Inc()

if len(certPEM) == 0 {
err = berrors.InternalServerError("no certificate returned by server")
Expand All @@ -778,8 +775,8 @@ func (ca *CertificateAuthorityImpl) issuePrecertificateInner(ctx context.Context
}
certDER := block.Bytes

ca.log.AuditInfof("Signing success: serial=[%s] names=[%s] csr=[%s] %s=[%s]",
serialHex, strings.Join(csr.DNSNames, ", "), hex.EncodeToString(csr.Raw), certType,
ca.log.AuditInfof("Signing success: serial=[%s] names=[%s] csr=[%s] precertificate=[%s]",
serialHex, strings.Join(csr.DNSNames, ", "), hex.EncodeToString(csr.Raw),
hex.EncodeToString(certDER))

return certDER, nil
Expand Down

0 comments on commit 4184dc3

Please sign in to comment.