Is it possible to use WireMock.Net.Aspire with https? #1507
Replies: 1 comment
|
Your diagnosis is right: the HTTPS listener needs a certificate inside the container. Trusting a development certificate on the host alone does not make its private key available there. There is an escape hatch in 2.8.0 even though the Aspire options don't expose certificate properties: The configuration shape is: var certPassword = builder.AddParameter("wiremock-cert-password", secret: true);
var wiremock = builder.AddWireMock("wiremock", o =>
{
o.HttpPorts = [9091];
o.WithAdditionalUrls("https://*:9091");
})
.WithBindMount("./https", "/https", isReadOnly: true)
.WithArgs(ctx =>
{
ctx.Args.Add("--X509CertificateFilePath");
ctx.Args.Add("/https/wiremock.pfx");
ctx.Args.Add("--X509CertificatePassword");
ctx.Args.Add(certPassword.Resource);
});Export a password-protected development PFX into that local directory first, and supply its password through the Aspire secret parameter. Microsoft's development-certificate export/mount instructions cover that part. Keep the PFX and password out of source control. Also change the additional listener from This is based on the 2.8.0 source rather than a run of your AppHost; it preserves the HTTP admin/health endpoint that the Aspire integration creates alongside the additional HTTPS listener. |
Uh oh!
There was an error while loading. Please reload this page.
I'm using WireMock.Net.Aspire 2.8.0 (due to Aspire.Hosting conflicts, I don't believe anything has changed in more recent versions) and attempting to run under a https address like this:
But this is failing to start with the following error:
I believe this is because the docker image doesn't have dev-certs setup by default, and there's nothing exposed to customize this through aspire?
All reactions