summary refs log tree commit diff
path: root/crypto/src/asn1/x509/CertificateList.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/x509/CertificateList.cs')
-rw-r--r--crypto/src/asn1/x509/CertificateList.cs31
1 files changed, 23 insertions, 8 deletions
diff --git a/crypto/src/asn1/x509/CertificateList.cs b/crypto/src/asn1/x509/CertificateList.cs
index 5d73cf411..ecf22e372 100644
--- a/crypto/src/asn1/x509/CertificateList.cs
+++ b/crypto/src/asn1/x509/CertificateList.cs
@@ -19,24 +19,39 @@ namespace Org.BouncyCastle.Asn1.X509
     public class CertificateList
         : Asn1Encodable
     {
-        private readonly TbsCertificateList	tbsCertList;
-        private readonly AlgorithmIdentifier sigAlgID;
-        private readonly DerBitString sig;
+        public static CertificateList GetInstance(object obj)
+        {
+            if (obj == null)
+                return null;
+            if (obj is CertificateList certificateList)
+                return certificateList;
+            return new CertificateList(Asn1Sequence.GetInstance(obj));
+        }
 
         public static CertificateList GetInstance(Asn1TaggedObject obj, bool explicitly)
         {
             return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
         }
 
-        public static CertificateList GetInstance(object obj)
+        public static CertificateList GetOptional(Asn1Encodable element)
         {
-            if (obj == null)
-                return null;
-            if (obj is CertificateList certificateList)
+            if (element == null)
+                throw new ArgumentNullException(nameof(element));
+
+            if (element is CertificateList certificateList)
                 return certificateList;
-            return new CertificateList(Asn1Sequence.GetInstance(obj));
+
+            Asn1Sequence asn1Sequence = Asn1Sequence.GetOptional(element);
+            if (asn1Sequence != null)
+                return new CertificateList(asn1Sequence);
+
+            return null;
         }
 
+        private readonly TbsCertificateList tbsCertList;
+        private readonly AlgorithmIdentifier sigAlgID;
+        private readonly DerBitString sig;
+
         private CertificateList(
             Asn1Sequence seq)
         {