From 7ab050c2de627e03b07e7a4b8970cd9fcfa593a6 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 27 Apr 2023 00:08:04 +0700 Subject: Check trust anchor count after filtering for nulls --- crypto/src/pkix/PkixParameters.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crypto/src/pkix/PkixParameters.cs b/crypto/src/pkix/PkixParameters.cs index 192a78780..67a75ba97 100644 --- a/crypto/src/pkix/PkixParameters.cs +++ b/crypto/src/pkix/PkixParameters.cs @@ -190,9 +190,7 @@ namespace Org.BouncyCastle.Pkix public virtual void SetTrustAnchors(ISet tas) { if (tas == null) - throw new ArgumentNullException("value"); - if (tas.Count < 1) - throw new ArgumentException("non-empty set required", "value"); + throw new ArgumentNullException(nameof(tas)); // Explicit copy to enforce type-safety this.trustAnchors = new HashSet(); @@ -203,9 +201,12 @@ namespace Org.BouncyCastle.Pkix trustAnchors.Add(ta); } } - } - /** + if (trustAnchors.Count < 1) + throw new ArgumentException("non-empty set required", nameof(tas)); + } + + /** * Returns the required constraints on the target certificate or attribute * certificate. The constraints are returned as an instance of * IX509Selector. If null, no constraints are -- cgit 1.4.1