简体   繁体   中英

How to parse CRL Number in Bouncy Castle X509Crl C# as BigInteger

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.

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));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM