summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-07-29 00:27:22 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-07-29 00:27:22 +0700
commit1275296e1cbaefbdcc970ed12c37b8e8d03ca777 (patch)
tree676a63aa2b5728b34e5e6711655f5227e836f34a
parentUse ReadOnlySpan in places (diff)
downloadBouncyCastle.NET-ed25519-1275296e1cbaefbdcc970ed12c37b8e8d03ca777.tar.xz
Make nextUpdate nullable
- see https://github.com/bcgit/bc-csharp/issues/371
-rw-r--r--crypto/src/ocsp/BasicOCSPRespGenerator.cs37
1 files changed, 9 insertions, 28 deletions
diff --git a/crypto/src/ocsp/BasicOCSPRespGenerator.cs b/crypto/src/ocsp/BasicOCSPRespGenerator.cs
index d4ec3df80..63d577404 100644
--- a/crypto/src/ocsp/BasicOCSPRespGenerator.cs
+++ b/crypto/src/ocsp/BasicOCSPRespGenerator.cs
@@ -32,30 +32,11 @@ namespace Org.BouncyCastle.Ocsp
 			internal DerGeneralizedTime    nextUpdate;
 			internal X509Extensions        extensions;
 
-			public ResponseObject(
+			internal ResponseObject(
 				CertificateID		certId,
 				CertificateStatus	certStatus,
 				DateTime			thisUpdate,
-				X509Extensions		extensions)
-				: this(certId, certStatus, new DerGeneralizedTime(thisUpdate), null, extensions)
-			{
-			}
-
-			public ResponseObject(
-				CertificateID		certId,
-				CertificateStatus	certStatus,
-				DateTime			thisUpdate,
-				DateTime			nextUpdate,
-				X509Extensions		extensions)
-				: this(certId, certStatus, new DerGeneralizedTime(thisUpdate), new DerGeneralizedTime(nextUpdate), extensions)
-			{
-			}
-
-			private ResponseObject(
-				CertificateID		certId,
-				CertificateStatus	certStatus,
-				DerGeneralizedTime	thisUpdate,
-				DerGeneralizedTime	nextUpdate,
+				DateTime?			nextUpdate,
 				X509Extensions		extensions)
 			{
 				this.certId = certId;
@@ -79,8 +60,8 @@ namespace Org.BouncyCastle.Ocsp
 						new RevokedInfo(new DerGeneralizedTime(rs.RevocationTime), revocationReason));
 				}
 
-				this.thisUpdate = thisUpdate;
-				this.nextUpdate = nextUpdate;
+				this.thisUpdate = new DerGeneralizedTime(thisUpdate);
+				this.nextUpdate = nextUpdate.HasValue ? new DerGeneralizedTime(nextUpdate.Value) : null;
 
 				this.extensions = extensions;
 			}
@@ -119,7 +100,7 @@ namespace Org.BouncyCastle.Ocsp
 			CertificateID		certID,
 			CertificateStatus	certStatus)
 		{
-			list.Add(new ResponseObject(certID, certStatus, DateTime.UtcNow, null));
+			list.Add(new ResponseObject(certID, certStatus, DateTime.UtcNow, null, null));
 		}
 
 		/**
@@ -134,7 +115,7 @@ namespace Org.BouncyCastle.Ocsp
 			CertificateStatus	certStatus,
 			X509Extensions		singleExtensions)
 		{
-			list.Add(new ResponseObject(certID, certStatus, DateTime.UtcNow, singleExtensions));
+			list.Add(new ResponseObject(certID, certStatus, DateTime.UtcNow, null, singleExtensions));
 		}
 
 		/**
@@ -148,7 +129,7 @@ namespace Org.BouncyCastle.Ocsp
 		public void AddResponse(
 			CertificateID		certID,
 			CertificateStatus	certStatus,
-			DateTime			nextUpdate,
+			DateTime?			nextUpdate,
 			X509Extensions		singleExtensions)
 		{
 			list.Add(new ResponseObject(certID, certStatus, DateTime.UtcNow, nextUpdate, singleExtensions));
@@ -167,7 +148,7 @@ namespace Org.BouncyCastle.Ocsp
 			CertificateID		certID,
 			CertificateStatus	certStatus,
 			DateTime			thisUpdate,
-			DateTime			nextUpdate,
+			DateTime?			nextUpdate,
 			X509Extensions		singleExtensions)
 		{
 			list.Add(new ResponseObject(certID, certStatus, thisUpdate, nextUpdate, singleExtensions));
@@ -230,7 +211,7 @@ namespace Org.BouncyCastle.Ocsp
 			DerSequence chainSeq = null;
 			if (chain != null && chain.Length > 0)
 			{
-				Asn1EncodableVector v = new Asn1EncodableVector();
+				Asn1EncodableVector v = new Asn1EncodableVector(chain.Length);
 				try
 				{
 					for (int i = 0; i != chain.Length; i++)