Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serial Number of a X.509 Certificate

I am programming a Certification Authority in java for a uni class, now I don't know what's the best option for the serial number of the Certificate.

  • Simple static counter from 0 to veryBigNumber
  • some huge BigInt random number

Is there any good reason for choosing one over the other... or none of them??

thanks,

like image 833
woolagaroo Avatar asked Jan 19 '10 20:01

woolagaroo


People also ask

What is the serial number of a certificate?

A serial number. This is a unique identifier assigned by the CA which issued the certificate. The serial number is unique within the CA which issued the certificate: no two certificates signed by the same CA certificate have the same serial number.

How long is a certificate serial number?

Certificate serial number requirements As per RFC 5280 §4.1. 2.2, serial numbers MUST be unique, not greater than 20 bytes long non-negative integer and at least 1 bit must be enabled in first byte.


2 Answers

I would recommend that you use a random number, but keep a list of those issued serial numbers in a database. This will allow for two things.

  1. You will never reissue the same serial number.
  2. You can tell from a certificate's serial number if it is even remotely valid.

Of course #1 requires that you check against the known list on generation and to generate a new random number if a collision occurs, and #2 isn't much of anything in terms of security or validation but an interesting prospect never-the-less.

like image 165
Jason Whitehorn Avatar answered Nov 15 '22 07:11

Jason Whitehorn


Technically counter from 0 to veryBigNumber is easier to implement than bigRandomNumber - because the serial numbers MUST be different.

However - you might not want to use a simple counter if you care about people knowing how many certificates you issued.

like image 21
laura Avatar answered Nov 15 '22 08:11

laura