From fe0347352da212319b6471a64ba42282b27bf3f7 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 26 Jan 2023 00:46:51 +0700 Subject: Avoid reparsing when possible --- crypto/src/ocsp/BasicOCSPResp.cs | 9 +++++---- crypto/src/ocsp/OCSPReq.cs | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'crypto/src/ocsp') diff --git a/crypto/src/ocsp/BasicOCSPResp.cs b/crypto/src/ocsp/BasicOCSPResp.cs index 6c8ad9eee..3e22931af 100644 --- a/crypto/src/ocsp/BasicOCSPResp.cs +++ b/crypto/src/ocsp/BasicOCSPResp.cs @@ -117,10 +117,11 @@ namespace Org.BouncyCastle.Ocsp { foreach (Asn1Encodable ae in certs) { - if (ae != null && ae.ToAsn1Object() is Asn1Sequence s) - { - result.Add(new X509Certificate(X509CertificateStructure.GetInstance(s))); - } + var c = X509CertificateStructure.GetInstance(ae); + if (c != null) + { + result.Add(new X509Certificate(c)); + } } } diff --git a/crypto/src/ocsp/OCSPReq.cs b/crypto/src/ocsp/OCSPReq.cs index cb2748780..194b6c9c7 100644 --- a/crypto/src/ocsp/OCSPReq.cs +++ b/crypto/src/ocsp/OCSPReq.cs @@ -165,9 +165,10 @@ namespace Org.BouncyCastle.Ocsp { foreach (Asn1Encodable ae in certs) { - if (ae != null && ae.ToAsn1Object() is Asn1Sequence s) + var c = X509CertificateStructure.GetInstance(ae); + if (c != null) { - result.Add(new X509Certificate(X509CertificateStructure.GetInstance(s))); + result.Add(new X509Certificate(c)); } } } -- cgit 1.4.1