mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(acm): reject RequestCertificate key algorithms real ACM does not support (#3044)
* fix(acm): reject RequestCertificate key algorithms real ACM does not support Real ACM only issues certificates for RSA_2048, EC_prime256v1, and EC_secp384r1 on RequestCertificate. RSA_1024, RSA_3072, RSA_4096, and EC_secp521r1 are rejected with a ValidationException, and the RSA_4096 message carries the account id where the region goes (an AWS quirk, replicated verbatim). The wider algorithm list remains valid for ImportCertificate. Closes #3027 * style(acm): drop em-dash from RSA_4096 test comment * test(acm): issue leaf certificates only for requestable key algorithms AcmServiceTest.issuesALeafOfTheRequestedAlgorithmSignedByTheLocalCa drove every KeyAlgorithm through RequestCertificate. RSA_1024, RSA_3072, RSA_4096, and EC_secp521r1 are now rejected there, matching real ACM, and their ValidationException is asserted in AcmEdgeCaseTest.
This commit is contained in:
1 parent
631df1dc01
commit
db6c419459
4 files changed
+47
-4
No files matched your search
@@ -398,8 +398,8 @@ class AcmEdgeCaseTest {
|
||||
// ==================== Key Algorithm Tests ====================
|
||||
|
||||
@Test
|
||||
void allKeyAlgorithmsSupported() {
|
||||
String[] algorithms = {"RSA_2048", "RSA_3072", "RSA_4096", "EC_prime256v1", "EC_secp384r1", "EC_secp521r1"};
|
||||
void requestableKeyAlgorithmsAccepted() {
|
||||
String[] algorithms = {"RSA_2048", "EC_prime256v1", "EC_secp384r1"};
|
||||
|
||||
for (String algo : algorithms) {
|
||||
given()
|
||||
@@ -418,4 +418,33 @@ class AcmEdgeCaseTest {
|
||||
.body("CertificateArn", startsWith("arn:aws:acm:"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void unsupportedKeyAlgorithmsRejected() {
|
||||
// Real ACM rejects these on RequestCertificate. The RSA_4096 message carries the
|
||||
// account id where the region goes, an AWS quirk replicated verbatim.
|
||||
Map<String, String> expected = Map.of(
|
||||
"RSA_1024", "Encryption Algorithm RSA_1024 is not supported in us-east-1 region",
|
||||
"RSA_3072", "Encryption Algorithm RSA_3072 is not supported in us-east-1 region",
|
||||
"RSA_4096", "Encryption Algorithm RSA_4096 is not supported in 000000000000 region",
|
||||
"EC_secp521r1", "Encryption Algorithm EC_secp521r1 is not supported in us-east-1 region");
|
||||
|
||||
for (Map.Entry<String, String> entry : expected.entrySet()) {
|
||||
given()
|
||||
.header("X-Amz-Target", "CertificateManager.RequestCertificate")
|
||||
.contentType(ACM_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"DomainName": "%s.example.com",
|
||||
"KeyAlgorithm": "%s"
|
||||
}
|
||||
""".formatted(entry.getKey().toLowerCase().replace("_", "-"), entry.getKey()))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo(entry.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class AcmServiceTest {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(KeyAlgorithm.class)
|
||||
@EnumSource(value = KeyAlgorithm.class, names = {"RSA_2048", "EC_prime256v1", "EC_secp384r1"})
|
||||
void issuesALeafOfTheRequestedAlgorithmSignedByTheLocalCa(KeyAlgorithm algorithm) throws Exception {
|
||||
Certificate cert = service.requestCertificate("api.example.test", List.of("*.example.test"),
|
||||
ValidationMethod.DNS, null, algorithm, null, null, Map.of(), REGION);
|
||||
|
||||
Reference in new issue
Block a user