Skip to content

Commit

Permalink
Merge pull request #50 from smallstep/mariano/serialnumber
Browse files Browse the repository at this point in the history
Format serial number bytes with 0 prefix
  • Loading branch information
maraino authored Mar 15, 2024
2 parents 8a18fc5 + 34ca4e8 commit f30cc1a
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions certformat.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (c *certificateShort) String() string {
var buf formatBuffer
buf.Writef("X.509v3 %s Certificate (%s) [Serial: %s]\n", c.Type, c.PublicKeyAlgorithm, c.SerialNumber)
sans := c.SANs
if len(c.Subject) > 0 {
if c.Subject != "" {
sans = append([]string{c.Subject}, sans...)
}
if len(sans) == 0 {
Expand Down Expand Up @@ -118,7 +118,7 @@ func (c *certificateRequestShort) String() string {
var buf formatBuffer
buf.Writef("X.509v3 Certificate Signing Request (%s)\n", c.PublicKeyAlgorithm)
sans := c.SANs
if len(c.Subject) > 0 {
if c.Subject != "" {
sans = append([]string{c.Subject}, sans...)
}
if len(sans) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion certinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ func CertificateText(cert *x509.Certificate) (string, error) {
fmt.Fprint(buf, "Certificate:\n")
fmt.Fprintf(buf, "%4sData:\n", "")
printVersion(cert.Version, buf)
fmt.Fprintf(buf, "%8sSerial Number: %d (%#x)\n", "", cert.SerialNumber, cert.SerialNumber)
fmt.Fprintf(buf, "%8sSerial Number: %d (%#x)\n", "", cert.SerialNumber, cert.SerialNumber.Bytes())
fmt.Fprintf(buf, "%4sSignature Algorithm: %s\n", "", cert.SignatureAlgorithm)

// Issuer information
Expand Down
2 changes: 1 addition & 1 deletion test_certs/leaf1.cert.pem
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 2 (0x2)
Serial Number: 2 (0x02)
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, ST=California, O=World Widget Authority, OU=Identity Affairs, CN=worldwidgetauthority.com/[email protected]
Validity
Expand Down
2 changes: 1 addition & 1 deletion test_certs/leaf1.cert.text
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 2 (0x2)
Serial Number: 2 (0x02)
Signature Algorithm: SHA256-RSA
Issuer: C=US,ST=California,O=World Widget Authority,OU=Identity Affairs,CN=worldwidgetauthority.com,[email protected]
Validity
Expand Down
2 changes: 1 addition & 1 deletion test_certs/leaf2.cert.pem
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 3 (0x3)
Serial Number: 3 (0x03)
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, ST=California, O=World Widget Authority, OU=Identity Affairs, CN=worldwidgetauthority.com/[email protected]
Validity
Expand Down
2 changes: 1 addition & 1 deletion test_certs/leaf2.cert.text
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 3 (0x3)
Serial Number: 3 (0x03)
Signature Algorithm: SHA256-RSA
Issuer: C=US,ST=California,O=World Widget Authority,OU=Identity Affairs,CN=worldwidgetauthority.com,[email protected]
Validity
Expand Down
2 changes: 1 addition & 1 deletion test_certs/leaf3.cert.pem
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 4 (0x4)
Serial Number: 4 (0x04)
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, ST=California, O=World Widget Authority, OU=Identity Affairs, CN=worldwidgetauthority.com/[email protected]
Validity
Expand Down
2 changes: 1 addition & 1 deletion test_certs/leaf3.cert.text
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 4 (0x4)
Serial Number: 4 (0x04)
Signature Algorithm: SHA256-RSA
Issuer: C=US,ST=California,O=World Widget Authority,OU=Identity Affairs,CN=worldwidgetauthority.com,[email protected]
Validity
Expand Down
2 changes: 1 addition & 1 deletion test_certs/leaf5.cert.pem
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 1 (0x1)
Serial Number: 1 (0x01)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=US, ST=California, O=World Widget Authority, OU=Identity Affairs, CN=worldwidgetauthority.com/[email protected]
Validity
Expand Down
2 changes: 1 addition & 1 deletion test_certs/leaf5.cert.text
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 1 (0x1)
Serial Number: 1 (0x01)
Signature Algorithm: SHA1-RSA
Issuer: C=US,ST=California,O=World Widget Authority,OU=Identity Affairs,CN=worldwidgetauthority.com,[email protected]
Validity
Expand Down
2 changes: 1 addition & 1 deletion test_certs/root1.cert.pem
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 1 (0x1)
Serial Number: 1 (0x01)
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, ST=California, O=World Widget Authority, OU=Identity Affairs, CN=worldwidgetauthority.com/[email protected]
Validity
Expand Down
2 changes: 1 addition & 1 deletion test_certs/root1.cert.text
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 1 (0x1)
Serial Number: 1 (0x01)
Signature Algorithm: SHA256-RSA
Issuer: C=US,ST=California,O=World Widget Authority,OU=Identity Affairs,CN=worldwidgetauthority.com,[email protected]
Validity
Expand Down

0 comments on commit f30cc1a

Please sign in to comment.