Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.
Python awsaws-emulatoraws-localaws-sdkdevtoolsdockerdynamodbec2emulatorlambdalocalstacklocalstack-alternativeministackmock-awsopen-sourcepythons3sqsterraform
fix(tls): name host.docker.internal in the generated certificate (#2339)
iot-rocketbe48901b9017
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0a3a47b3..180945f0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,7 @@ Versioning follows [Semantic Versioning](https://semver.org/).- **Route 53 — VPC associations for private hosted zones** — `AssociateVPCWithHostedZone`, `DisassociateVPCFromHostedZone` and `ListHostedZonesByVPC` (paged with `MaxItems` and `NextToken`). They refuse a public zone (`PublicZoneVPCAssociation`), a VPC already associated with a zone of the same name (`ConflictingDomainExists`), a VPC the zone doesn't have (404 `VPCAssociationNotFound`) and the zone's last VPC (`LastVPCAssociation`). Contributed by @kharabasz.### Fixed+- **TLS — the generated certificate names `host.docker.internal`** — with `USE_SSL=1` and the Docker Lambda executor, functions reach the gateway as `https://host.docker.internal:<port>`, a name the generated certificate lacked, so every SDK call and callback from a container failed hostname verification; the certificate now carries it, and a cached one without it is regenerated. Contributed by @iot-rocket.- **SQS — FIFO dedup hit returns the current request's MD5s** — a `SendMessage` (or `SendMessageBatch` entry) whose `MessageDeduplicationId` was already in the 5-minute window answered with the first message's `MD5OfMessageBody` and `MD5OfMessageAttributes`; AWS keeps the first message but reports the digests of the request just sent, and SDKs that verify them (.NET, Java) threw `MD5 hash mismatch` on every replay whose body or attributes differed. The response now carries the current request's digests; `MessageId` and `SequenceNumber` are still the first message's. Contributed by @vanessah07.- **S3 — `EU` location constraint** — since 1.5.28, `CreateBucket` from an eu-west-1 endpoint refused the legacy `EU` constraint with `IllegalLocationConstraintException`, and a bucket created with it elsewhere was homed in a region called `EU`. As on AWS, eu-west-1 now accepts `EU` and homes the bucket in eu-west-1, `GetBucketLocation` answers `EU` for it, and other regional endpoints still refuse it. The AWS SDK for .NET sends `EU` for eu-west-1 by default.- **WAF v2 — `CreateIPSet` and `CreateRuleGroup` refuse a duplicate name** — a second IP set or rule group with the name and scope of an existing one is now refused with `WAFDuplicateItemException`, as AWS does and as `CreateWebACL` and `CreateRegexPatternSet` already did. Both stored the duplicate silently, so a client that retries a create after losing the response ended up with two. Contributed by @OS-kiranmalsetty.diff --git a/ministack/core/tls.py b/ministack/core/tls.pyindex 061e398b..6bc0f2a8 100644--- a/ministack/core/tls.py+++ b/ministack/core/tls.py@@ -64,7 +64,8 @@ def iot_endpoint_hosts() -> "list[str]":def _generated_cert_names() -> "list[str]":- return cognito_idp_hosts() + iot_endpoint_hosts()+ # Docker Lambda containers reach the gateway as host.docker.internal.+ return ["host.docker.internal"] + cognito_idp_hosts() + iot_endpoint_hosts()def ca_bundle_path(cert_path: str) -> "str | None":diff --git a/tests/test_tls.py b/tests/test_tls.pyindex 93e3f4fa..2f2f3e2b 100644--- a/tests/test_tls.py+++ b/tests/test_tls.py@@ -422,6 +422,25 @@ def test_generated_cert_is_a_server_certificate_not_a_ca(tmp_path, monkeypatch):assert verify.returncode == 0, verify.stdout + verify.stderr+def test_generated_cert_names_the_docker_gateway_host(tmp_path, monkeypatch):+ """Docker Lambdas dial https://host.docker.internal:<port>; a cert cached without that name is replaced."""+ from ministack.core import tls++ _fresh_tls(tmp_path, monkeypatch)+ tls_dir = tmp_path / "ministack-tls"+ tls_dir.mkdir()+ names = "".join(f"DNS:{h}," for h in tls.cognito_idp_hosts() + tls.iot_endpoint_hosts())+ subprocess.run([+ "openssl", "req", "-x509", "-newkey", "rsa:2048", "-nodes",+ "-keyout", str(tls_dir / "server.key"), "-out", str(tls_dir / "server.crt"),+ "-days", "1", "-subj", "/CN=old", "-addext", "basicConstraints=critical,CA:FALSE",+ "-addext", f"subjectAltName={names}DNS:localhost",+ ], check=True, capture_output=True)+ cert, _ = tls.resolve_tls_material()+ assert cert == str(tls_dir / "server.crt")+ assert _checkhost(cert, "host.docker.internal")++def test_cached_ca_certificate_is_regenerated(tmp_path, monkeypatch):from ministack.core import tls