summary refs log tree commit diff
path: root/crypto/src/x509/X509CertPairParser.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/x509/X509CertPairParser.cs')
-rw-r--r--crypto/src/x509/X509CertPairParser.cs21
1 files changed, 14 insertions, 7 deletions
diff --git a/crypto/src/x509/X509CertPairParser.cs b/crypto/src/x509/X509CertPairParser.cs
index 82612599b..89a8a8e96 100644
--- a/crypto/src/x509/X509CertPairParser.cs
+++ b/crypto/src/x509/X509CertPairParser.cs
@@ -62,15 +62,22 @@ namespace Org.BouncyCastle.X509
 
 			try
 			{
-				PushbackStream pis = new PushbackStream(inStream);
-				int tag = pis.ReadByte();
+                int tag = inStream.ReadByte();
+                if (tag < 0)
+                    return null;
 
-				if (tag < 0)
-					return null;
+                if (inStream.CanSeek)
+                {
+                    inStream.Seek(-1L, SeekOrigin.Current);
+                }
+                else
+                {
+                    PushbackStream pis = new PushbackStream(inStream);
+                    pis.Unread(tag);
+                    inStream = pis;
+                }
 
-				pis.Unread(tag);
-
-				return ReadDerCrossCertificatePair(pis);
+                return ReadDerCrossCertificatePair(inStream);
 			}
 			catch (Exception e)
 			{