0

Given a X509Crl object from BouncyCastle in C#, how can you access the CRL Number extension, parse it as BigInteger and increment it?

This can be helpful for when you want to increment the CRL Number by one in order to create a new updated CRL from an old one.

Radwa Sherif
  • 61
  • 1
  • 9

1 Answers1

1

If you have a X509Crl object in BouncyCastle C# and you would like to access the CrlNumber object in order to increment it and create a new CRL, this is how to do it. (More details on creating CRLs in this questions).

X509Crl prevCrl = ... // read it from somewhere or pass it as a function parameter 
... 
Asn1OctetString prevCrlNum = prevCrl.GetExtensionValue(X509Extensions.CrlNumber);
Asn1Object obj = X509ExtensionUtilities.FromExtensionValue(prevCrlNum);
BigInteger prevCrlNumVal = DerInteger.GetInstance(obj).PositiveValue;
CrlNumber nextCrlNum = new CrlNumber(prevCrlNum.Add(BigInteger.One));
Radwa Sherif
  • 61
  • 1
  • 9