Skip to content

Commit

Permalink
Merge pull request #109 from jsha/format-string
Browse files Browse the repository at this point in the history
Always use %016x when formatting shortSerial.
  • Loading branch information
jsha committed Apr 23, 2015
2 parents 6c8f6a2 + 32e159d commit 3814c95
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ca/certificate-authority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ func TestIssueCertificate(t *testing.T) {
}

// Verify that the cert got stored in the DB
shortSerial := fmt.Sprintf("%x", cert.SerialNumber)[0:16]
shortSerial := fmt.Sprintf("%016x", cert.SerialNumber)[0:16]
_, err = sa.GetCertificate(shortSerial)
test.AssertNotError(t, err,
fmt.Sprintf("Certificate %x not found in database", shortSerial))
fmt.Sprintf("Certificate %016x not found in database", shortSerial))
}

// Test that the CA rejects CSRs with no names
Expand Down
2 changes: 1 addition & 1 deletion ra/registration-authority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func TestNewCertificate(t *testing.T) {
test.AssertNotError(t, err, "Failed to issue certificate")
parsedCert, err := x509.ParseCertificate(cert.DER)
test.AssertNotError(t, err, "Failed to parse certificate")
shortSerial := fmt.Sprintf("%x", parsedCert.SerialNumber)[0:16]
shortSerial := fmt.Sprintf("%016x", parsedCert.SerialNumber)[0:16]

// Verify that cert shows up and is as expected
dbCert, err := sa.GetCertificate(shortSerial)
Expand Down
2 changes: 1 addition & 1 deletion sa/storage-authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func (ssa *SQLStorageAuthority) AddCertificate(certDER []byte) (digest string, e
if err != nil {
return
}
serial := fmt.Sprintf("%x", parsedCertificate.SerialNumber)
serial := fmt.Sprintf("%016x", parsedCertificate.SerialNumber)

tx, err := ssa.db.Begin()
if err != nil {
Expand Down

0 comments on commit 3814c95

Please sign in to comment.