Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -186,12 +186,7 @@ public SecurityConfig(ConfigurationSource configuration) {
HDDS_X509_RENEW_GRACE_DURATION_DEFAULT);
renewalGracePeriod = Duration.parse(renewalGraceDurationString);

if (maxCertDuration.compareTo(defaultCertDuration) < 0) {
LOG.error("Certificate duration {} should not be greater than Maximum " +
"Certificate duration {}", maxCertDuration, defaultCertDuration);
throw new IllegalArgumentException("Certificate duration should not be " +
"greater than maximum Certificate duration");
}
validateCertificateValidityConfig();

this.externalRootCaCert = this.configuration.get(
HDDS_X509_ROOTCA_CERTIFICATE_FILE,
Expand Down Expand Up @@ -228,6 +223,44 @@ public SecurityConfig(ConfigurationSource configuration) {
TimeUnit.MILLISECONDS);
}

/**
* Check for certificate validity configuration.
*/
private void validateCertificateValidityConfig() {
if (maxCertDuration.isNegative() || maxCertDuration.isZero()) {
LOG.error("Certificate maxDuration {} should not be zero or negative",
Comment thread
ashishkumar50 marked this conversation as resolved.
Outdated
maxCertDuration);
throw new IllegalArgumentException("Certificate maxDuration should not " +
"be zero or negative");
}
if (defaultCertDuration.isNegative() || defaultCertDuration.isZero()) {
LOG.error("Certificate duration {} should not be Zero or negative",
defaultCertDuration);
throw new IllegalArgumentException("Certificate duration should not be " +
"negative or zero");
}
if (renewalGracePeriod.isNegative() || renewalGracePeriod.isZero()) {
LOG.error("Certificate grace duration {} should not be Zero or negative",
renewalGracePeriod);
throw new IllegalArgumentException("Certificate grace duration should " +
"not be negative or zero");
}

if (maxCertDuration.compareTo(defaultCertDuration) < 0) {
LOG.error("Certificate duration {} should not be greater than Maximum " +
"Certificate duration {}", defaultCertDuration, maxCertDuration);
throw new IllegalArgumentException("Certificate duration should not " +
"be greater than maximum Certificate duration");
}
if (defaultCertDuration.compareTo(renewalGracePeriod) < 0) {
LOG.error("Grace Certificate duration {} should not be greater than " +
"Certificate duration {}", renewalGracePeriod,
defaultCertDuration);
throw new IllegalArgumentException("Grace Certificate duration should " +
"not be greater than Certificate duration");
}
}

/**
* Returns the CRL Name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_SECURITY_SSL_KEYSTORE_RELOAD_INTERVAL;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_SECURITY_SSL_TRUSTSTORE_RELOAD_INTERVAL;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_X509_DEFAULT_DURATION;
import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_X509_RENEW_GRACE_DURATION;
import static org.apache.hadoop.hdds.HddsConfigKeys.OZONE_METADATA_DIRS;
import static org.apache.hadoop.hdds.scm.ScmConfigKeys.HDDS_DATANODE_DIR_KEY;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_SECURITY_ENABLED_KEY;
Expand Down Expand Up @@ -131,6 +132,7 @@ public void setup() throws Exception {
conf.setInt(HDDS_KEY_LEN, 1024);
// certificate lives for 5s
conf.set(HDDS_X509_DEFAULT_DURATION, "PT5S");
conf.set(HDDS_X509_RENEW_GRACE_DURATION, "PT2S");
conf.set(HDDS_SECURITY_SSL_KEYSTORE_RELOAD_INTERVAL, "1s");
conf.set(HDDS_SECURITY_SSL_TRUSTSTORE_RELOAD_INTERVAL, "1s");

Expand Down