diff options
Diffstat (limited to '')
-rw-r--r-- | crypto/src/x509/X509CrlParser.cs | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/crypto/src/x509/X509CrlParser.cs b/crypto/src/x509/X509CrlParser.cs index d830bb9a6..59f7a23c4 100644 --- a/crypto/src/x509/X509CrlParser.cs +++ b/crypto/src/x509/X509CrlParser.cs @@ -140,22 +140,29 @@ namespace Org.BouncyCastle.X509 return null; } - PushbackStream pis = new PushbackStream(inStream); - int tag = pis.ReadByte(); - - if (tag < 0) - return null; - - pis.Unread(tag); - - if (tag != 0x30) // assume ascii PEM encoded. + int tag = inStream.ReadByte(); + if (tag < 0) + return null; + + if (inStream.CanSeek) + { + inStream.Seek(-1L, SeekOrigin.Current); + } + else + { + PushbackStream pis = new PushbackStream(inStream); + pis.Unread(tag); + inStream = pis; + } + + if (tag != 0x30) // assume ascii PEM encoded. { - return ReadPemCrl(pis); + return ReadPemCrl(inStream); } Asn1InputStream asn1 = lazyAsn1 - ? new LazyAsn1InputStream(pis) - : new Asn1InputStream(pis); + ? new LazyAsn1InputStream(inStream) + : new Asn1InputStream(inStream); return ReadDerCrl(asn1); } |