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:
BingEdward authored and GitHub committed 2026-09-06 23:33:21 -04:00
1 parent 631df1dc01
commit db6c419459
4 files changed
+47 -4

No files matched your search

@@ -46,6 +46,9 @@ public class AcmService implements ResourceProvider {
private static final int MAX_TAG_VALUE_LENGTH = 256;
private static final int MAX_SANS = 100;
private static final int MAX_DOMAIN_LENGTH = 253;
/** Key algorithms real ACM accepts for RequestCertificate; the wider enum stays valid for ImportCertificate. */
private static final Set<KeyAlgorithm> REQUESTABLE_KEY_ALGORITHMS =
EnumSet.of(KeyAlgorithm.RSA_2048, KeyAlgorithm.EC_prime256v1, KeyAlgorithm.EC_secp384r1);
private final StorageBackend<String, Certificate> store;
private final CertificateGenerator certificateGenerator;
private final FlociCertificateAuthority certificateAuthority;
@@ -113,6 +116,7 @@ public class AcmService implements ResourceProvider {
}
KeyAlgorithm alg = keyAlgorithm != null ? keyAlgorithm : KeyAlgorithm.RSA_2048;
validateRequestableKeyAlgorithm(alg, region);
// Check idempotency with parameter validation
if (idempotencyToken != null && !idempotencyToken.isEmpty()) {
@@ -670,6 +674,16 @@ public class AcmService implements ResourceProvider {
}
}
private void validateRequestableKeyAlgorithm(KeyAlgorithm alg, String region) {
if (REQUESTABLE_KEY_ALGORITHMS.contains(alg)) {
return;
}
// Real ACM quirk: the RSA_4096 message carries the account id where the region goes.
String location = alg == KeyAlgorithm.RSA_4096 ? regionResolver.getAccountId() : region;
throw new AwsException("ValidationException",
"Encryption Algorithm " + alg.name() + " is not supported in " + location + " region", 400);
}
private void validateSans(List<String> sans) {
if (sans != null && sans.size() > MAX_SANS) {
throw new AwsException("ValidationException",