diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-03-06 19:43:25 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-03-06 19:43:25 +0700 |
commit | f93624749322b60eb96c80d466ea234a1a46d4c4 (patch) | |
tree | 780a228fa70aa25c44842ee5d20538f453a620f2 /crypto/src/pkix | |
parent | Avoid recoding issuer name (diff) | |
download | BouncyCastle.NET-ed25519-f93624749322b60eb96c80d466ea234a1a46d4c4.tar.xz |
Refactoring in Asn1
Diffstat (limited to 'crypto/src/pkix')
-rw-r--r-- | crypto/src/pkix/PkixCertPath.cs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/crypto/src/pkix/PkixCertPath.cs b/crypto/src/pkix/PkixCertPath.cs index a2ea3074d..950b999b2 100644 --- a/crypto/src/pkix/PkixCertPath.cs +++ b/crypto/src/pkix/PkixCertPath.cs @@ -191,20 +191,22 @@ namespace Org.BouncyCastle.Pkix { if (Platform.EqualsIgnoreCase("PkiPath", encoding)) { - Asn1InputStream derInStream = new Asn1InputStream(inStream); - if (!(derInStream.ReadObject() is Asn1Sequence asn1Sequence)) - { - throw new CertificateException( - "input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath"); - } + using (var asn1In = new Asn1InputStream(inStream, int.MaxValue, leaveOpen: true)) + { + if (!(asn1In.ReadObject() is Asn1Sequence asn1Sequence)) + { + throw new CertificateException( + "input stream does not contain a ASN1 SEQUENCE while reading PkiPath encoded data to load CertPath"); + } - var certArray = asn1Sequence.MapElements( - element => new X509Certificate(X509CertificateStructure.GetInstance(element.ToAsn1Object()))); + var certArray = asn1Sequence.MapElements( + element => new X509Certificate(X509CertificateStructure.GetInstance(element.ToAsn1Object()))); - Array.Reverse(certArray); + Array.Reverse(certArray); - certs = new List<X509Certificate>(certArray); - } + certs = new List<X509Certificate>(certArray); + } + } else if (Platform.EqualsIgnoreCase("PEM", encoding) || Platform.EqualsIgnoreCase("PKCS7", encoding)) { |