From d882f5d8d51534b92e460365771f999138f71ad1 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 11 Nov 2021 20:49:19 +0700 Subject: Trim stack trace --- crypto/src/asn1/Asn1Encodable.cs | 4 ++-- crypto/src/asn1/Asn1Object.cs | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'crypto') diff --git a/crypto/src/asn1/Asn1Encodable.cs b/crypto/src/asn1/Asn1Encodable.cs index 247b0e0bf..15918afb0 100644 --- a/crypto/src/asn1/Asn1Encodable.cs +++ b/crypto/src/asn1/Asn1Encodable.cs @@ -21,14 +21,14 @@ namespace Org.BouncyCastle.Asn1 public byte[] GetEncoded() { MemoryStream bOut = new MemoryStream(); - EncodeTo(bOut); + ToAsn1Object().EncodeTo(bOut); return bOut.ToArray(); } public byte[] GetEncoded(string encoding) { MemoryStream bOut = new MemoryStream(); - EncodeTo(bOut, encoding); + ToAsn1Object().EncodeTo(bOut, encoding); return bOut.ToArray(); } 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(); } /// Create a base ASN.1 object from a byte array. -- cgit 1.4.1