summary refs log tree commit diff
path: root/crypto/src/asn1/Asn1Object.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/Asn1Object.cs')
-rw-r--r--crypto/src/asn1/Asn1Object.cs8
1 files changed, 6 insertions, 2 deletions
diff --git a/crypto/src/asn1/Asn1Object.cs b/crypto/src/asn1/Asn1Object.cs
index 67c0f37c4..e6498060d 100644
--- a/crypto/src/asn1/Asn1Object.cs
+++ b/crypto/src/asn1/Asn1Object.cs
@@ -8,12 +8,16 @@ namespace Org.BouncyCastle.Asn1
     {
         public override void EncodeTo(Stream output)
         {
-            Asn1OutputStream.Create(output).WriteObject(this);
+            Asn1OutputStream asn1Out = Asn1OutputStream.Create(output);
+            Encode(asn1Out, true);
+            asn1Out.FlushInternal();
         }
 
         public override void EncodeTo(Stream output, string encoding)
         {
-            Asn1OutputStream.Create(output, encoding).WriteObject(this);
+            Asn1OutputStream asn1Out = Asn1OutputStream.Create(output, encoding);
+            Encode(asn1Out, true);
+            asn1Out.FlushInternal();
         }
 
         /// <summary>Create a base ASN.1 object from a byte array.</summary>