fix(acm): reject mismatched certificate private keys (#5987)

Preserve existing certificates when an import supplies the wrong key.
This commit is contained in:
David Phillips authored and GitHub committed 2026-10-19 09:00:35 -04:00
1 parent b14537baa7
commit 84dfb77f99
5 files changed
+111 -2

No files matched your search

@@ -402,7 +402,9 @@ public class AcmService implements ResourceProvider {
// Parse and validate private key
try {
Pem.parsePrivateKey(privateKeyPem);
if (!Pem.isPair(Pem.parsePrivateKey(privateKeyPem), x509Cert.getPublicKey())) {
throw new IllegalArgumentException("The private key does not match the certificate");
}
} catch (Exception e) {
throw new AwsException("ValidationException", "Invalid private key: " + e.getMessage(), 400);
}