From 9f562ae2423c550b95b3e00e6bcbeb6616b2a034 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Fri, 21 Feb 2020 18:06:14 +0700 Subject: Refactoring --- crypto/src/pkix/Rfc3280CertPathUtilities.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'crypto/src/pkix/Rfc3280CertPathUtilities.cs') diff --git a/crypto/src/pkix/Rfc3280CertPathUtilities.cs b/crypto/src/pkix/Rfc3280CertPathUtilities.cs index c703194a4..d6594f4ad 100644 --- a/crypto/src/pkix/Rfc3280CertPathUtilities.cs +++ b/crypto/src/pkix/Rfc3280CertPathUtilities.cs @@ -245,12 +245,11 @@ namespace Org.BouncyCastle.Pkix if (!(PkixCertPathValidatorUtilities.IsSelfIssued(cert) && (i < n))) { X509Name principal = cert.SubjectDN; - Asn1InputStream aIn = new Asn1InputStream(principal.GetEncoded()); Asn1Sequence dns; try { - dns = DerSequence.GetInstance(aIn.ReadObject()); + dns = Asn1Sequence.GetInstance(principal.GetEncoded()); } catch (Exception e) { @@ -357,7 +356,7 @@ namespace Org.BouncyCastle.Pkix DerObjectIdentifier subjectDomainPolicy = null; try { - Asn1Sequence mapping = DerSequence.GetInstance(mappings[j]); + Asn1Sequence mapping = Asn1Sequence.GetInstance(mappings[j]); issuerDomainPolicy = DerObjectIdentifier.GetInstance(mapping[0]); subjectDomainPolicy = DerObjectIdentifier.GetInstance(mapping[1]); @@ -400,7 +399,7 @@ namespace Org.BouncyCastle.Pkix Asn1Sequence certPolicies = null; try { - certPolicies = DerSequence.GetInstance( + certPolicies = Asn1Sequence.GetInstance( PkixCertPathValidatorUtilities.GetExtensionValue(cert, X509Extensions.CertificatePolicies)); } catch (Exception e) @@ -1167,10 +1166,10 @@ namespace Org.BouncyCastle.Pkix * omitted and a distribution point name of the certificate * issuer. */ - Asn1Object issuer = null; + X509Name issuer; try { - issuer = new Asn1InputStream(cert.IssuerDN.GetEncoded()).ReadObject(); + issuer = X509Name.GetInstance(cert.IssuerDN.GetEncoded()); } catch (Exception e) { @@ -1598,7 +1597,7 @@ namespace Org.BouncyCastle.Pkix Asn1Sequence pc = null; try { - pc = DerSequence.GetInstance( + pc = Asn1Sequence.GetInstance( PkixCertPathValidatorUtilities.GetExtensionValue(cert, X509Extensions.PolicyConstraints)); } catch (Exception e) @@ -1653,7 +1652,7 @@ namespace Org.BouncyCastle.Pkix Asn1Sequence pc = null; try { - pc = DerSequence.GetInstance( + pc = Asn1Sequence.GetInstance( PkixCertPathValidatorUtilities.GetExtensionValue(cert, X509Extensions.PolicyConstraints)); } catch (Exception e) @@ -1708,7 +1707,7 @@ namespace Org.BouncyCastle.Pkix NameConstraints nc = null; try { - Asn1Sequence ncSeq = DerSequence.GetInstance( + Asn1Sequence ncSeq = Asn1Sequence.GetInstance( PkixCertPathValidatorUtilities.GetExtensionValue(cert, X509Extensions.NameConstraints)); if (ncSeq != null) { @@ -2042,7 +2041,7 @@ namespace Org.BouncyCastle.Pkix Asn1Sequence pc = null; try { - pc = DerSequence.GetInstance( + pc = Asn1Sequence.GetInstance( PkixCertPathValidatorUtilities.GetExtensionValue(cert, X509Extensions.PolicyConstraints)); } catch (Exception e) @@ -2415,7 +2414,7 @@ namespace Org.BouncyCastle.Pkix Asn1Sequence certPolicies = null; try { - certPolicies = DerSequence.GetInstance( + certPolicies = Asn1Sequence.GetInstance( PkixCertPathValidatorUtilities.GetExtensionValue(cert, X509Extensions.CertificatePolicies)); } catch (Exception e) -- cgit 1.4.1