From 2de510c0d1e7969eee14473ba71b161bf5d01e15 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 6 Jun 2024 20:20:28 +0700 Subject: Refactoring in Asn1.Ess --- crypto/src/asn1/x509/IssuerSerial.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'crypto/src/asn1/x509') diff --git a/crypto/src/asn1/x509/IssuerSerial.cs b/crypto/src/asn1/x509/IssuerSerial.cs index 09b6dae18..8e7ba1fa6 100644 --- a/crypto/src/asn1/x509/IssuerSerial.cs +++ b/crypto/src/asn1/x509/IssuerSerial.cs @@ -19,6 +19,21 @@ namespace Org.BouncyCastle.Asn1.X509 return new IssuerSerial(Asn1Sequence.GetInstance(obj, explicitly)); } + public static IssuerSerial GetOptional(Asn1Encodable element) + { + if (element == null) + throw new ArgumentNullException(nameof(element)); + + if (element is IssuerSerial issuerSerial) + return issuerSerial; + + Asn1Sequence asn1Sequence = Asn1Sequence.GetOptional(element); + if (asn1Sequence != null) + return new IssuerSerial(asn1Sequence); + + return null; + } + private readonly GeneralNames issuer; private readonly DerInteger serial; private readonly DerBitString issuerUid; -- cgit 1.4.1