X509 serial number uses Java
•
Java
I need to get some data from x509 certificate
If I open a certificate file in windows, its serial number is displayed in this format
ex. 39 65 70 eb d8 9f 28 20 4e c2 a0 6b 98 48 31 0d
I'm trying to get the same data using Java After getting it loaded, I use it
x509.getSerialNumber(); and result is : 76292708057987193002565060032465481997
So what's the difference between the two? The result I want is the last one
Solution
Windows displays the hexadecimal representation of the serial number, while Java starts from x509certificate Getserialnumber() returns BigInteger result
To display BigInteger as a hexadecimal value, simply call toString (16)
BigInteger bi = new BigInteger("76292708057987193002565060032465481997"); System.out.println(bi.toString(16));
Output:
396570ebd89f28204ec2a06b9848310d
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码