mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 21:10:32 +01:00
Wiki: Add HTTPS usage inside Docker #303
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @winseros on GitHub (Oct 9, 2020).
Greetings.
Some history. We use WireMock to run our unit tests inside
Docker. The other day we had to mock a service whose official client library was nailed to work through HTTPS only. Trying to make an HTTPS mock through WireMock, we were surprised it worked nice onWindows, but insideDockerwe were receiving SSL validation errors at connection time.The reasons behind the behavior - are WireMock-Net/WireMock.Net#379, where the support of default aspnetcore development certificates was added,
and https://github.com/dotnet/aspnetcore/issues/7246, that prevents default dev certificates from being trusted on
Linux/Docker.There is a way to make WireMock run trusted HTTPS inside
DockerI'd like to share.Make the
localhost.conffile of content:Note the
1.3.6.1.4.1.311.84.1.1 = DER:01it is critical for aspnet for recognizing the cert.Generate the cert:
Grab the
localhost.pfxandlocalhost.crtand throw them into the target system. In case ofDockerthat would look:Profit. The system has the aspnetcore dev cert trusted.
Ideally I'd like those 4 steps to be added into the project Wiki so others won't have to spend all the time I did to find a solution.
Best regards.
@StefH commented on GitHub (Oct 10, 2020):
Hello @winseros,
I can surely add this to the docker wiki: https://github.com/WireMock-Net/WireMock.Net-docker/wiki
However wouldn't it be a better idea to apply this fix to the Linux docker image, so that by default the https works?
(And can you describe the error when this is not applied?)
@winseros commented on GitHub (Oct 11, 2020):
Hello. I'm not sure if the issue is a case of
WireMock.Net-docker. Probably I had to call the issue "Linux" instead of "Docker".I made a demo project to show the details:
https://github.com/winseros/wiremock.net-https-demo-project
In short, there is a 3rd party HTTPClient library, hardcoded to work only through https (so you can't use HTTP for tests). In order to make WireMock HTTPS tests work, on
Windowsit is enough to rundotnet dev-certs https --trust, but onLinuxor inDockeryou have to run the commands from https://github.com/WireMock-Net/WireMock.Net-docker/issues/26#issue-718565995@StefH commented on GitHub (Oct 11, 2020):
OK. I see.
I did add your information to this page:
https://github.com/WireMock-Net/WireMock.Net/wiki/Using-HTTPS-(SSL)
Can you verify it's correct?
@winseros commented on GitHub (Oct 11, 2020):
That's correct. Thank you!
@StefH commented on GitHub (Oct 11, 2020):
Hello @winseros ; thank you very much for researching the issue + solution.