summary refs log tree commit diff
path: root/crypto/src/asn1/x509/IssuerSerial.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2024-06-06 20:20:28 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2024-06-06 20:20:28 +0700
commit2de510c0d1e7969eee14473ba71b161bf5d01e15 (patch)
tree524bd77b97f17d6c2656fc3de2d21684971fb982 /crypto/src/asn1/x509/IssuerSerial.cs
parentRefactoring in Asn1.Cms.Ecc (diff)
downloadBouncyCastle.NET-ed25519-2de510c0d1e7969eee14473ba71b161bf5d01e15.tar.xz
Refactoring in Asn1.Ess
Diffstat (limited to 'crypto/src/asn1/x509/IssuerSerial.cs')
-rw-r--r--crypto/src/asn1/x509/IssuerSerial.cs15
1 files changed, 15 insertions, 0 deletions
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;