summary refs log tree commit diff
path: root/crypto/src/asn1/DERExternal.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/DERExternal.cs')
-rw-r--r--crypto/src/asn1/DERExternal.cs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crypto/src/asn1/DERExternal.cs b/crypto/src/asn1/DERExternal.cs
index d6255bb93..ae707a2f5 100644
--- a/crypto/src/asn1/DERExternal.cs
+++ b/crypto/src/asn1/DERExternal.cs
@@ -17,21 +17,21 @@ namespace Org.BouncyCastle.Asn1
             {
                 return (DerExternal)obj;
             }
-            if (obj is Asn1Encodable)
+            else if (obj is IAsn1Convertible)
             {
-                Asn1Object asn1 = ((Asn1Encodable)obj).ToAsn1Object();
-                if (asn1 is DerExternal)
-                    return (DerExternal)asn1;
+                Asn1Object asn1Object = ((IAsn1Convertible)obj).ToAsn1Object();
+                if (asn1Object is DerExternal)
+                    return (DerExternal)asn1Object;
             }
-            if (obj is byte[])
+            else if (obj is byte[])
             {
                 try
                 {
                     return GetInstance(FromByteArray((byte[])obj));
                 }
-                catch (Exception e)
+                catch (IOException e)
                 {
-                    throw new ArgumentException("encoding error in GetInstance: " + e.ToString(), "obj");
+                    throw new ArgumentException("failed to construct external from byte[]: " + e.Message);
                 }
             }
 
@@ -47,7 +47,7 @@ namespace Org.BouncyCastle.Asn1
                 return GetInstance(baseObject);
             }
 
-            return Asn1Sequence.GetInstance(taggedObject, false).ToAsn1External();
+            return Asn1Sequence.GetInstance(baseObject).ToAsn1External();
         }
 
 		private readonly DerObjectIdentifier directReference;