Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -310,30 +310,32 @@ private void validateCertificateValidityConfig() {
throw new IllegalArgumentException(msg);
}

if (caCheckInterval.isNegative() || caCheckInterval.isZero()) {
String msg = "Property " + HDDS_X509_CA_ROTATION_CHECK_INTERNAL +
" should not be zero or negative";
LOG.error(msg);
throw new IllegalArgumentException(msg);
}
if (autoCARotationEnabled) {
if (caCheckInterval.isNegative() || caCheckInterval.isZero()) {
String msg = "Property " + HDDS_X509_CA_ROTATION_CHECK_INTERNAL +
" should not be zero or negative";
LOG.error(msg);
throw new IllegalArgumentException(msg);
}

if (caCheckInterval.compareTo(renewalGracePeriod) >= 0) {
throw new IllegalArgumentException("Property value of " +
HDDS_X509_CA_ROTATION_CHECK_INTERNAL +
" should be smaller than " + HDDS_X509_RENEW_GRACE_DURATION);
}
if (caCheckInterval.compareTo(renewalGracePeriod) >= 0) {
throw new IllegalArgumentException("Property value of " +
HDDS_X509_CA_ROTATION_CHECK_INTERNAL +
" should be smaller than " + HDDS_X509_RENEW_GRACE_DURATION);
}

if (caAckTimeout.isNegative() || caAckTimeout.isZero()) {
String msg = "Property " + HDDS_X509_CA_ROTATION_ACK_TIMEOUT +
" should not be zero or negative";
LOG.error(msg);
throw new IllegalArgumentException(msg);
}
if (caAckTimeout.isNegative() || caAckTimeout.isZero()) {
String msg = "Property " + HDDS_X509_CA_ROTATION_ACK_TIMEOUT +
" should not be zero or negative";
LOG.error(msg);
throw new IllegalArgumentException(msg);
}

if (caAckTimeout.compareTo(renewalGracePeriod) >= 0) {
throw new IllegalArgumentException("Property value of " +
HDDS_X509_CA_ROTATION_ACK_TIMEOUT +
" should be smaller than " + HDDS_X509_RENEW_GRACE_DURATION);
if (caAckTimeout.compareTo(renewalGracePeriod) >= 0) {
throw new IllegalArgumentException("Property value of " +
HDDS_X509_CA_ROTATION_ACK_TIMEOUT +
" should be smaller than " + HDDS_X509_RENEW_GRACE_DURATION);
}
}

if (tokenSanityChecksEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_X509_CA_ROTATION_ACK_TIMEOUT;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_X509_CA_ROTATION_CHECK_INTERNAL;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_X509_CA_ROTATION_ENABLED;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_X509_CA_ROTATION_TIME_OF_DAY;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_X509_GRACE_DURATION_TOKEN_CHECKS_ENABLED;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_X509_RENEW_GRACE_DURATION;
Expand Down Expand Up @@ -97,6 +98,7 @@ public void init() throws IOException, TimeoutException,
.set(HddsConfigKeys.OZONE_METADATA_DIRS, testDir.getAbsolutePath());
ozoneConfig
.setBoolean(HDDS_X509_GRACE_DURATION_TOKEN_CHECKS_ENABLED, false);
ozoneConfig.setBoolean(HDDS_X509_CA_ROTATION_ENABLED, true);
scm = Mockito.mock(StorageContainerManager.class);
securityConfig = new SecurityConfig(ozoneConfig);
scmCertClient = new SCMCertificateClient(securityConfig, null, scmID, cID,
Expand Down Expand Up @@ -178,6 +180,15 @@ public void testProperties() {
} catch (Exception e) {
fail("Should succeed");
}

// invalid property value is ignored when auto rotation is disabled.
ozoneConfig.setBoolean(HDDS_X509_CA_ROTATION_ENABLED, false);
ozoneConfig.set(HDDS_X509_CA_ROTATION_CHECK_INTERNAL, "P28D");
try {
rootCARotationManager = new RootCARotationManager(scm);
} catch (Exception e) {
fail("Should succeed");
}
}

@Test
Expand Down