Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename int64 timestamp related protobuf fields to <fieldname>NS #7069

Merged
merged 5 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .codespell.ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ uint
vas
ede
vai
nowns
20 changes: 10 additions & 10 deletions ca/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ func (ca *certificateAuthorityImpl) IssuePrecertificate(ctx context.Context, iss
nowNanos := ca.clk.Now().UnixNano()
expiresNanos := validity.NotAfter.UnixNano()
_, err = ca.sa.AddSerial(ctx, &sapb.AddSerialRequest{
Serial: serialHex,
RegID: regID,
Created: nowNanos,
Expires: expiresNanos,
Serial: serialHex,
RegID: regID,
CreatedNS: nowNanos,
ExpiresNS: expiresNanos,
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -297,9 +297,9 @@ func (ca *certificateAuthorityImpl) IssueCertificateForPrecertificate(ctx contex
serialHex, req.RegistrationID, names, hex.EncodeToString(certDER))

_, err = ca.sa.AddCertificate(ctx, &sapb.AddCertificateRequest{
Der: certDER,
RegID: req.RegistrationID,
Issued: ca.clk.Now().UnixNano(),
Der: certDER,
RegID: req.RegistrationID,
IssuedNS: ca.clk.Now().UnixNano(),
})
if err != nil {
ca.log.AuditErrf("Failed RPC to store at SA: serial=[%s], cert=[%s], issuerID=[%d], regID=[%d], orderID=[%d], err=[%v]",
Expand All @@ -312,8 +312,8 @@ func (ca *certificateAuthorityImpl) IssueCertificateForPrecertificate(ctx contex
Serial: core.SerialToString(precert.SerialNumber),
Der: certDER,
Digest: core.Fingerprint256(certDER),
Issued: precert.NotBefore.UnixNano(),
Expires: precert.NotAfter.UnixNano(),
IssuedNS: precert.NotBefore.UnixNano(),
ExpiresNS: precert.NotAfter.UnixNano(),
}, nil
}

Expand Down Expand Up @@ -417,7 +417,7 @@ func (ca *certificateAuthorityImpl) issuePrecertificateInner(ctx context.Context
_, err = ca.sa.AddPrecertificate(context.Background(), &sapb.AddCertificateRequest{
Der: lintCertBytes,
RegID: issueReq.RegistrationID,
Issued: nowNanos,
IssuedNS: nowNanos,
IssuerNameID: int64(issuer.Cert.NameID()),
OcspNotReady: true,
})
Expand Down
8 changes: 4 additions & 4 deletions ca/crl.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ func (ci *crlImpl) GenerateCRL(stream capb.CRLGenerator_GenerateCRLServer) error
}

func (ci *crlImpl) metadataToTemplate(meta *capb.CRLMetadata) (*crl_x509.RevocationList, error) {
if meta.IssuerNameID == 0 || meta.ThisUpdate == 0 {
if meta.IssuerNameID == 0 || meta.ThisUpdateNS == 0 {
return nil, errors.New("got incomplete metadata message")
}
thisUpdate := time.Unix(0, meta.ThisUpdate)
thisUpdate := time.Unix(0, meta.ThisUpdateNS)
number := bcrl.Number(thisUpdate)

return &crl_x509.RevocationList{
Expand All @@ -216,10 +216,10 @@ func (ci *crlImpl) entryToRevokedCertificate(entry *corepb.CRLEntry) (*crl_x509.
return nil, err
}

if entry.RevokedAt == 0 {
if entry.RevokedAtNS == 0 {
return nil, errors.New("got empty or zero revocation timestamp")
}
revokedAt := time.Unix(0, entry.RevokedAt)
revokedAt := time.Unix(0, entry.RevokedAtNS)

var reason *int
if entry.Reason != 0 {
Expand Down
50 changes: 25 additions & 25 deletions ca/crl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestGenerateCRL(t *testing.T) {
Payload: &capb.GenerateCRLRequest_Metadata{
Metadata: &capb.CRLMetadata{
IssuerNameID: 1,
ThisUpdate: time.Now().UnixNano(),
ThisUpdateNS: time.Now().UnixNano(),
},
},
}
Expand All @@ -93,15 +93,15 @@ func TestGenerateCRL(t *testing.T) {
Payload: &capb.GenerateCRLRequest_Metadata{
Metadata: &capb.CRLMetadata{
IssuerNameID: int64(testCtx.boulderIssuers[0].Cert.NameID()),
ThisUpdate: time.Now().UnixNano(),
ThisUpdateNS: time.Now().UnixNano(),
},
},
}
ins <- &capb.GenerateCRLRequest{
Payload: &capb.GenerateCRLRequest_Metadata{
Metadata: &capb.CRLMetadata{
IssuerNameID: int64(testCtx.boulderIssuers[0].Cert.NameID()),
ThisUpdate: time.Now().UnixNano(),
ThisUpdateNS: time.Now().UnixNano(),
},
},
}
Expand All @@ -118,9 +118,9 @@ func TestGenerateCRL(t *testing.T) {
ins <- &capb.GenerateCRLRequest{
Payload: &capb.GenerateCRLRequest_Entry{
Entry: &corepb.CRLEntry{
Serial: "123",
Reason: 1,
RevokedAt: time.Now().UnixNano(),
Serial: "123",
Reason: 1,
RevokedAtNS: time.Now().UnixNano(),
},
},
}
Expand All @@ -137,9 +137,9 @@ func TestGenerateCRL(t *testing.T) {
ins <- &capb.GenerateCRLRequest{
Payload: &capb.GenerateCRLRequest_Entry{
Entry: &corepb.CRLEntry{
Serial: "deadbeefdeadbeefdeadbeefdeadbeefdead",
Reason: 1,
RevokedAt: 0,
Serial: "deadbeefdeadbeefdeadbeefdeadbeefdead",
Reason: 1,
RevokedAtNS: 0,
},
},
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestGenerateCRL(t *testing.T) {
Payload: &capb.GenerateCRLRequest_Metadata{
Metadata: &capb.CRLMetadata{
IssuerNameID: int64(testCtx.boulderIssuers[0].Cert.NameID()),
ThisUpdate: time.Now().UnixNano(),
ThisUpdateNS: time.Now().UnixNano(),
},
},
}
Expand Down Expand Up @@ -201,52 +201,52 @@ func TestGenerateCRL(t *testing.T) {
Payload: &capb.GenerateCRLRequest_Metadata{
Metadata: &capb.CRLMetadata{
IssuerNameID: int64(testCtx.boulderIssuers[0].Cert.NameID()),
ThisUpdate: time.Now().UnixNano(),
ThisUpdateNS: time.Now().UnixNano(),
},
},
}
ins <- &capb.GenerateCRLRequest{
Payload: &capb.GenerateCRLRequest_Entry{
Entry: &corepb.CRLEntry{
Serial: "000000000000000000000000000000000000",
RevokedAt: time.Now().UnixNano(),
Serial: "000000000000000000000000000000000000",
RevokedAtNS: time.Now().UnixNano(),
// Reason 0, Unspecified, is omitted.
},
},
}
ins <- &capb.GenerateCRLRequest{
Payload: &capb.GenerateCRLRequest_Entry{
Entry: &corepb.CRLEntry{
Serial: "111111111111111111111111111111111111",
Reason: 1, // keyCompromise
RevokedAt: time.Now().UnixNano(),
Serial: "111111111111111111111111111111111111",
Reason: 1, // keyCompromise
RevokedAtNS: time.Now().UnixNano(),
},
},
}
ins <- &capb.GenerateCRLRequest{
Payload: &capb.GenerateCRLRequest_Entry{
Entry: &corepb.CRLEntry{
Serial: "444444444444444444444444444444444444",
Reason: 4, // superseded
RevokedAt: time.Now().UnixNano(),
Serial: "444444444444444444444444444444444444",
Reason: 4, // superseded
RevokedAtNS: time.Now().UnixNano(),
},
},
}
ins <- &capb.GenerateCRLRequest{
Payload: &capb.GenerateCRLRequest_Entry{
Entry: &corepb.CRLEntry{
Serial: "555555555555555555555555555555555555",
Reason: 5, // cessationOfOperation
RevokedAt: time.Now().UnixNano(),
Serial: "555555555555555555555555555555555555",
Reason: 5, // cessationOfOperation
RevokedAtNS: time.Now().UnixNano(),
},
},
}
ins <- &capb.GenerateCRLRequest{
Payload: &capb.GenerateCRLRequest_Entry{
Entry: &corepb.CRLEntry{
Serial: "999999999999999999999999999999999999",
Reason: 9, // privilegeWithdrawn
RevokedAt: time.Now().UnixNano(),
Serial: "999999999999999999999999999999999999",
Reason: 9, // privilegeWithdrawn
RevokedAtNS: time.Now().UnixNano(),
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion ca/ocsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (oi *ocspImpl) GenerateOCSP(ctx context.Context, req *capb.GenerateOCSPRequ
NextUpdate: now.Add(oi.ocspLifetime - time.Second),
}
if tbsResponse.Status == ocsp.Revoked {
tbsResponse.RevokedAt = time.Unix(0, req.RevokedAt)
tbsResponse.RevokedAt = time.Unix(0, req.RevokedAtNS)
tbsResponse.RevocationReason = int(req.Reason)
}

Expand Down
Loading