ribbybibby / ssl_exporter

Exports Prometheus metrics for TLS certificates
Apache License 2.0
504 stars 95 forks source link

What format is the serial number in? #123

Closed alvnov closed 3 months ago

alvnov commented 1 year ago

Hi all What is the format of serial_no="nnn.." key serial number? I see 39 digits in decimal, but I need hexadecimal. But the conversion from decimal to hexadecimal does not give me anything. I do not have with the correct serial number (

ribbybibby commented 6 months ago

The serial number comes from the SerialNumber field of the x509.Certificate type. This is a big.Int, which we call String() on.

According to the description for String:

String returns the decimal representation of x as generated by x.Text(10).

And then for Text:

Text returns the string representation of x in the given base. Base must be between 2 and 62, inclusive. The result uses the lower-case letters 'a' to 'z' for digit values 10 to 35, and the upper-case letters 'A' to 'Z' for digit values 36 to 61. No prefix (such as "0x") is added to the string. If x is a nil pointer it returns "".