summary refs log tree commit diff
path: root/crypto/src/asn1
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1')
-rw-r--r--crypto/src/asn1/cmp/CmpCertificate.cs18
1 files changed, 17 insertions, 1 deletions
diff --git a/crypto/src/asn1/cmp/CmpCertificate.cs b/crypto/src/asn1/cmp/CmpCertificate.cs
index bc9844911..e30eccca4 100644
--- a/crypto/src/asn1/cmp/CmpCertificate.cs
+++ b/crypto/src/asn1/cmp/CmpCertificate.cs
@@ -13,9 +13,25 @@ namespace Org.BouncyCastle.Asn1.Cmp
                 return null;
             if (obj is CmpCertificate cmpCertificate)
                 return cmpCertificate;
+            if (obj is X509CertificateStructure certificate)
+                return new CmpCertificate(certificate);
             if (obj is Asn1TaggedObject taggedObject)
                 return new CmpCertificate(taggedObject);
-            return new CmpCertificate(X509CertificateStructure.GetInstance(obj));
+
+            Asn1Object asn1Object = null;
+            if (obj is IAsn1Convertible asn1Convertible)
+            {
+                asn1Object = asn1Convertible.ToAsn1Object();
+            }
+            else if (obj is byte[] bytes)
+            {
+                asn1Object = Asn1Object.FromByteArray(bytes);
+            }
+
+            if (asn1Object is Asn1TaggedObject asn1TaggedObject)
+                return new CmpCertificate(asn1TaggedObject);
+
+            return new CmpCertificate(X509CertificateStructure.GetInstance(asn1Object ?? obj));
         }
 
         public static CmpCertificate GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)