You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "sarankk (via GitHub)" <gi...@apache.org> on 2024/02/23 06:10:28 UTC
[PR] Check for expired certificate during start up validation [cassandra-analytics]
sarankk opened a new pull request, #43:
URL: https://github.com/apache/cassandra-analytics/pull/43
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] CASSANDRA-19424 Check for expired certificate during start up validation [cassandra-analytics]
Posted by "frankgh (via GitHub)" <gi...@apache.org>.
frankgh commented on code in PR #43:
URL: https://github.com/apache/cassandra-analytics/pull/43#discussion_r1515113234
##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/validation/KeyStoreValidation.java:
##########
@@ -81,6 +84,15 @@ public void validate()
throw new RuntimeException("KeyStore is empty");
}
+ for (Enumeration<String> aliases = keyStore.aliases(); aliases.hasMoreElements();)
+ {
+ Certificate cert = keyStore.getCertificate(aliases.nextElement());
+ if (cert instanceof X509Certificate)
+ {
+ ((X509Certificate) cert).checkValidity();
+ }
+ }
Review Comment:
ah, I just realized that the second loop looks for a PK< and it if finds it, it exits the validation as successful. Please disregard this comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] CASSANDRA-19424 Check for expired certificate during start up validation [cassandra-analytics]
Posted by "frankgh (via GitHub)" <gi...@apache.org>.
frankgh commented on code in PR #43:
URL: https://github.com/apache/cassandra-analytics/pull/43#discussion_r1515102552
##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/validation/KeyStoreValidation.java:
##########
@@ -81,6 +84,15 @@ public void validate()
throw new RuntimeException("KeyStore is empty");
}
+ for (Enumeration<String> aliases = keyStore.aliases(); aliases.hasMoreElements();)
+ {
+ Certificate cert = keyStore.getCertificate(aliases.nextElement());
+ if (cert instanceof X509Certificate)
+ {
+ ((X509Certificate) cert).checkValidity();
+ }
+ }
Review Comment:
Can we collapse the for lops in lines 87 and 96:
```suggestion
for (Enumeration<String> aliases = keyStore.aliases(); aliases.hasMoreElements();)
{
String alias = aliases.nextElement();
Certificate cert = keyStore.getCertificate(alias);
if (cert instanceof X509Certificate)
{
((X509Certificate) cert).checkValidity();
}
Key key = keyStore.getKey(alias, password);
if (key != null && key instanceof PrivateKey)
{
return; // KeyStore contains a private key
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] CASSANDRA-19424 Check for expired certificate during start up validation [cassandra-analytics]
Posted by "sarankk (via GitHub)" <gi...@apache.org>.
sarankk commented on code in PR #43:
URL: https://github.com/apache/cassandra-analytics/pull/43#discussion_r1515057459
##########
cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/validation/KeyStoreValidationTests.java:
##########
@@ -97,4 +98,15 @@ public void testValidKeyStore()
Throwable throwable = validation.perform();
assertNull(throwable);
}
+
+ @Test
+ public void testExpiredKeyStore()
+ {
+ SecretsProvider secrets = TestSecretsProvider.forKeyStore("PKCS12", "keystore-expired.p12", "qwerty");
+ KeyStoreValidation validation = new KeyStoreValidation(secrets);
+
+ Throwable throwable = validation.perform();
+ assertInstanceOf(RuntimeException.class, throwable);
+ assertThat(throwable.getMessage()).startsWith("Certificate expired, valid NotAfter: ");
Review Comment:
Updated to `Certificate expired. ` instead
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] CASSANDRA-19424 Check for expired certificate during start up validation [cassandra-analytics]
Posted by "frankgh (via GitHub)" <gi...@apache.org>.
frankgh commented on code in PR #43:
URL: https://github.com/apache/cassandra-analytics/pull/43#discussion_r1509704327
##########
cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/validation/KeyStoreValidationTests.java:
##########
@@ -97,4 +98,15 @@ public void testValidKeyStore()
Throwable throwable = validation.perform();
assertNull(throwable);
}
+
+ @Test
+ public void testExpiredKeyStore()
+ {
+ SecretsProvider secrets = TestSecretsProvider.forKeyStore("PKCS12", "keystore-expired.p12", "qwerty");
+ KeyStoreValidation validation = new KeyStoreValidation(secrets);
+
+ Throwable throwable = validation.perform();
+ assertInstanceOf(RuntimeException.class, throwable);
+ assertThat(throwable.getMessage()).startsWith("Certificate expired, valid NotAfter: ");
Review Comment:
the error message is odd, Should we just say:
`Certificate expired. NotAfter:` instead?
##########
cassandra-analytics-core/src/main/java/org/apache/cassandra/spark/validation/KeyStoreValidation.java:
##########
@@ -81,6 +85,15 @@ public void validate()
throw new RuntimeException("KeyStore is empty");
}
+ for (Enumeration<String> aliases = keyStore.aliases(); aliases.hasMoreElements();)
+ {
+ Certificate cert = keyStore.getCertificate(aliases.nextElement());
+ if (cert instanceof X509Certificate && !(cert instanceof PemX509Certificate))
Review Comment:
I don't think we need to worry about `PemX509Certificate`s.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
Re: [PR] CASSANDRA-19424 Check for expired certificate during start up validation [cassandra-analytics]
Posted by "yifan-c (via GitHub)" <gi...@apache.org>.
yifan-c merged PR #43:
URL: https://github.com/apache/cassandra-analytics/pull/43
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org