Add constructor from template CRL
1 files changed, 34 insertions, 1 deletions
diff --git a/crypto/src/x509/X509V2CRLGenerator.cs b/crypto/src/x509/X509V2CRLGenerator.cs
index 01d7aee4a..d7c72d673 100644
--- a/crypto/src/x509/X509V2CRLGenerator.cs
+++ b/crypto/src/x509/X509V2CRLGenerator.cs
@@ -24,7 +24,40 @@ namespace Org.BouncyCastle.X509
tbsGen = new V2TbsCertListGenerator();
}
- /**
+ /// <summary>Create a builder for a version 2 CRL, initialised with another CRL.</summary>
+ /// <param name="template">Template CRL to base the new one on.</param>
+ public X509V2CrlGenerator(X509Crl template)
+ : this(template.CertificateList)
+ {
+ }
+
+ public X509V2CrlGenerator(CertificateList template)
+ {
+ tbsGen = new V2TbsCertListGenerator();
+ tbsGen.SetIssuer(template.Issuer);
+ tbsGen.SetThisUpdate(template.ThisUpdate);
+ tbsGen.SetNextUpdate(template.NextUpdate);
+
+ AddCrl(new X509Crl(template));
+
+ var extensions = template.TbsCertList.Extensions;
+ if (extensions != null)
+ {
+ foreach (var oid in extensions.ExtensionOids)
+ {
+ if (X509Extensions.AltSignatureAlgorithm.Equals(oid) ||
+ X509Extensions.AltSignatureValue.Equals(oid))
+ {
+ continue;
+ }
+
+ X509Extension ext = extensions.GetExtension(oid);
+ extGenerator.AddExtension(oid, ext.critical, ext.Value.GetOctets());
+ }
+ }
+ }
+
+ /**
* reset the generator
*/
public void Reset()
|