summary refs log tree commit diff
path: root/crypto/src/x509/X509CertPairParser.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-03-05 14:45:49 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-03-05 14:45:49 +0700
commit6b59dbbece3b1509b83b8479259a3c6059e9a60b (patch)
tree3dca66ea9a1e8aa02ac6099cde5844155783bd7b /crypto/src/x509/X509CertPairParser.cs
parentRefactor Asn1Set classes (diff)
downloadBouncyCastle.NET-ed25519-6b59dbbece3b1509b83b8479259a3c6059e9a60b.tar.xz
Support 'leaveOpen' in Asn1 streams
Diffstat (limited to 'crypto/src/x509/X509CertPairParser.cs')
-rw-r--r--crypto/src/x509/X509CertPairParser.cs11
1 files changed, 5 insertions, 6 deletions
diff --git a/crypto/src/x509/X509CertPairParser.cs b/crypto/src/x509/X509CertPairParser.cs
index 26b417898..95ba522c8 100644
--- a/crypto/src/x509/X509CertPairParser.cs
+++ b/crypto/src/x509/X509CertPairParser.cs
@@ -13,13 +13,12 @@ namespace Org.BouncyCastle.X509
 	{
 		private Stream currentStream;
 
-		private X509CertificatePair ReadDerCrossCertificatePair(
-			Stream inStream)
+		private X509CertificatePair ReadDerCrossCertificatePair(Stream inStream)
 		{
-			Asn1InputStream dIn = new Asn1InputStream(inStream);//, ProviderUtil.getReadLimit(in));
-			Asn1Sequence seq = (Asn1Sequence)dIn.ReadObject();
-			CertificatePair pair = CertificatePair.GetInstance(seq);
-			return new X509CertificatePair(pair);
+            using (var asn1In = new Asn1InputStream(inStream, int.MaxValue, leaveOpen: true))
+            {
+                return new X509CertificatePair(CertificatePair.GetInstance(asn1In.ReadObject()));
+            }
 		}
 
 		/// <summary>