Skip to content

Commit

Permalink
added method to allow setting of ThisUpdate field - relates to github b…
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Dec 8, 2023
1 parent d3d007e commit 96ea1c4
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
40 changes: 40 additions & 0 deletions pkix/src/main/java/org/bouncycastle/cert/X509v2CRLBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,46 @@ private Extension doGetExtension(ASN1ObjectIdentifier oid)
return exts.getExtension(oid);
}

/**
* Set the date by which the next CRL will become available.
*
* @param date date of next CRL update.
* @return the current builder.
*/
public X509v2CRLBuilder setThisUpdate(
Date date)
{
return this.setThisUpdate(new Time(date));
}

/**
* Set the date by which the next CRL will become available.
*
* @param date date of next CRL update.
* @param dateLocale locale to be used for date interpretation.
* @return the current builder.
*/
public X509v2CRLBuilder setThisUpdate(
Date date,
Locale dateLocale)
{
return this.setThisUpdate(new Time(date, dateLocale));
}

/**
* Set the date by which the next CRL will become available.
*
* @param date date of next CRL update.
* @return the current builder.
*/
public X509v2CRLBuilder setThisUpdate(
Time date)
{
tbsGen.setThisUpdate(date);

return this;
}

/**
* Set the date by which the next CRL will become available.
*
Expand Down
10 changes: 10 additions & 0 deletions pkix/src/test/java/org/bouncycastle/cert/test/CertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2513,6 +2513,16 @@ public void checkCRLCreation2()
{
fail("CRL entry reasonCode not found");
}

crlGen = new X509v2CRLBuilder(crlHolder);

crlGen.setThisUpdate(new Date(crlHolder.getThisUpdate().getTime() + 50000));
crlGen.setNextUpdate(new Date(crlHolder.getNextUpdate().getTime() + 100000));

X509CRLHolder hldr2 = crlGen.build(new JcaContentSignerBuilder("SHA256withRSAEncryption").setProvider(BC).build(pair.getPrivate()));

isEquals(hldr2.getThisUpdate().getTime(), crlHolder.getThisUpdate().getTime() + 50000);
isEquals(hldr2.getNextUpdate().getTime(), crlHolder.getNextUpdate().getTime() + 100000);
}

public void checkCRLCreation3()
Expand Down

0 comments on commit 96ea1c4

Please sign in to comment.