-2

I have a certificate data (byte array):

var cert = new X509Certificate2(certBytes);
var serialBytes = cert.GetSerialNumber();
var serialString = cert.SerialNumber;

when converting serialBytes to hex format:

BitConverter.ToString(serialBytes).Replace("-","")

it gives a different value than serialString

mshwf
  • 7,009
  • 12
  • 59
  • 133

1 Answers1

1

Because you should read the documentation:

X509Certificate.GetSerialNumber Returns the serial number of the X.509v3 certificate as an array of bytes in little-endian order.

X509Certificate2.SerialNumber Gets the serial number of a certificate as a big-endian hexadecimal string.

Crypt32
  • 12,850
  • 2
  • 41
  • 70