Skip to content

Commit a1235c3

Browse files
jmagneJack Magne
and
Jack Magne
authored
Address Bug 1462291 - CRL autoupdate from CS.cfg (dogtagpki#503)
This fix allows the admin to request that a change to this crl CS.cfg setting: ca.crl.MasterCRL.autoUpdateInterval=xxx This fix will allow the system to attempt to use the new value of auto update immediately. The previous longstanding behavior was to have the new interval take affect, AFTER the currently scheduled nextUpdate time. What this fix does is allow the use of a new CS.cfg parameter: ca.crl.MasterCRL.autoUpdateInterval.effectiveAtStart=true This parameter must be inserted before a restart to allow this behavior to take place at all. Without the param everything should be working as normal. After changing the CS.cfg value, the server must be restarted. At this point the delay time for the next update will be calculated based on the new auto update interval. Previously the code would simply ignore the new calculated value and take whatever is already encoded into the "nextUpdate" field of the crl. This fix allows the new value to be accepted. Here are some caveats on how this thing behaves: 1. If the autoUpdate interval is made smaller , this thing works as expected, having the next update take place in roughly the amount of time in the new interval. 2. If making the interval smaller, makes the calculated next update in the past, the update will occur now and then the nextUpdate will be calculated with the new schedule.. 3. If the admin makes the autoUpdate interval larger, the behavior is a little different. Due to the fact that the calculations made with the new interval, is based off of starting with the time stamp for "yesterday" or the very first daily update from yesterday, the new nextUPdate time calculated may be less than simply adding the the new interval to the last update. This fix was coded by allowing the current very comnplicated algorithm to calculate the nextUpdate do it's thing while at the end of the process, this code simply chooses what is calculated instead of what is already encoded within the crl's nextUpdate field. Therefore if the new param is never set, nothing changes. This param should be used with care. If the agent goes to the display crl page, the new value can easily be viewed as well as the debug log. 4. After the operation takes place the flag inside the server will be cleared and this feature will no longer be attempted while the server is running. 5. The admin must clear the schedulUpdated setting before the restart to assure normal operation after the next restart. Co-authored-by: Jack Magne <[email protected]>
1 parent 63368b0 commit a1235c3

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

base/ca/src/com/netscape/ca/CRLIssuingPoint.java

+45-2
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,13 @@ public class CRLIssuingPoint implements ICRLIssuingPoint, Runnable {
359359

360360
private boolean mSaveMemory = false;
361361

362+
/**
363+
* One time config flag that we have an updated schedule and we want it
364+
* followed immediately after startup.
365+
*/
366+
367+
private boolean mAutoUpdateIntervalEffectiveAtStart = false;
368+
362369
/**
363370
* Constructs a CRL issuing point from instantiating from class name.
364371
* CRL Issuing point must be followed by method call init(CA, id, config);
@@ -797,6 +804,9 @@ protected void initConfig(CRLIssuingPointConfig config) throws EBaseException {
797804
CMS.getUserMessage("CMS_BASE_INVALID_PROPERTY_1",
798805
PROP_END_SERIAL, "BigInteger", "positive number"));
799806
}
807+
808+
mAutoUpdateIntervalEffectiveAtStart = config.getAutoUpdateIntervalEffectiveAtStart();
809+
logger.debug("CRLIssuingPoint.initConfig : mAutoUpdateIntervalEffectiveAtStart: " + mAutoUpdateIntervalEffectiveAtStart);
800810
}
801811

802812
/**
@@ -860,6 +870,9 @@ private void initCRL() throws EBaseException {
860870
mLastFullUpdate = null;
861871

862872
mNextUpdate = crlRecord.getNextUpdate();
873+
874+
logger.debug("CRLIssuingPoint.initCRL: mNextUpdate: " + mNextUpdate);
875+
863876
if (isDeltaCRLEnabled()) {
864877
mNextDeltaUpdate = (mNextUpdate != null) ? new Date(mNextUpdate.getTime()) : null;
865878
}
@@ -1603,7 +1616,10 @@ private long findNextUpdate(boolean fromLastUpdate, boolean delta) {
16031616
long next = 0L;
16041617
long nextUpdate = 0L;
16051618

1606-
logger.debug("findNextUpdate: fromLastUpdate: " + fromLastUpdate + " delta: " + delta);
1619+
logger.debug("CRLIssuingPoint.findNextUpdate: mLastUpdate: " + mLastUpdate);
1620+
logger.debug("CRLIssuingPoint.findNextUpdate: mNextUpdate: " + mNextUpdate);
1621+
logger.debug("CRLIssuingPoint.findNextUpdate: mAutoUpdateInterval: " + mAutoUpdateInterval / 60000);
1622+
logger.debug("CRLIssuingPOint.findNextUpdate: lastUpdate: " + new Date(lastUpdate));
16071623

16081624
int numberOfDays = (int) ((startOfToday - lastUpdateDay) / oneDay);
16091625
if (numberOfDays > 0 && mDailyUpdates.size() > 1 &&
@@ -1767,8 +1783,33 @@ private long findNextUpdate(boolean fromLastUpdate, boolean delta) {
17671783
}
17681784
}
17691785

1786+
logger.debug("CRLIssuingPoint.findNextUpdate: nextUpdate : " + new Date(nextUpdate) + " next: " + new Date(next));
1787+
17701788
if (fromLastUpdate && nextUpdate > 0 && (nextUpdate < next || nextUpdate >= now)) {
1771-
next = nextUpdate;
1789+
// We have the one time schedule updated flag set in CS.cfg, which means
1790+
// we want the schedule adhered to now instead of waiting for the next update for it
1791+
// to take effect.
1792+
// Here the variable "next" has the newly calculated nextUpdate value
1793+
// Here the variable "nextUpdate" contains the nextUpdate value from the previous schedule
1794+
if (mAutoUpdateIntervalEffectiveAtStart) {
1795+
// Check and see if the new schedule has taken us into the past:
1796+
if(next <= now ) {
1797+
mNextUpdate = new Date(now);
1798+
logger.debug("CRLIssuingPoint.findNextUpdate: schedule updated to the past. Making mNextUpdate now: " + mNextUpdate);
1799+
next = now;
1800+
} else {
1801+
//alter the value of the nextUpdate to be the time calculated from the new schedule
1802+
mNextUpdate = new Date(next);
1803+
}
1804+
1805+
logger.debug("CRLIssuingPoint.findNextUpdate: taking updated schedule value: " + mNextUpdate);
1806+
// Now clear it since we only want this once upon startup.
1807+
mAutoUpdateIntervalEffectiveAtStart = false;
1808+
} else {
1809+
logger.debug("CRLIssuingPoint.findNextUpdate: taking current schedule's nextUpdate value: " + new Date(nextUpdate));
1810+
//Normal behavior where the previous or current shedule's nextUpdate time is observed.
1811+
next = nextUpdate;
1812+
}
17721813
}
17731814

17741815
logger.debug("findNextUpdate: "
@@ -2830,6 +2871,8 @@ void generateFullCRL(
28302871
Date thisUpdate,
28312872
Date nextUpdate) throws EBaseException {
28322873

2874+
logger.debug("generateFullCRL: thisUpdate: " + thisUpdate + " nextUpdate: " + nextUpdate);
2875+
28332876
mSplits[6] -= System.currentTimeMillis();
28342877
if (mNextDeltaCRLNumber.compareTo(mNextCRLNumber) > 0) {
28352878
mNextCRLNumber = mNextDeltaCRLNumber;

base/ca/src/com/netscape/ca/CRLIssuingPointConfig.java

+8
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,12 @@ public BigInteger getCRLEndSerialNo() throws EBaseException {
293293
public void setCRLEndSerialNo(BigInteger crlEndSerialNo) {
294294
putBigInteger("crlEndSerialNo", crlEndSerialNo);
295295
}
296+
297+
public boolean getAutoUpdateIntervalEffectiveAtStart() throws EBaseException {
298+
return getBoolean("autoUpdateInterval.effectiveAtStart",false);
299+
}
300+
301+
public void setAutoUpdateIntervalEffectiveAtStart(Boolean updated) {
302+
putBoolean("autoUpdateInterval.effectiveAtStart",updated);
303+
}
296304
}

0 commit comments

Comments
 (0)