Overriding the default ssl certificate via file.
Hey, I have a question regarding the configuration of SSL certificate. As I understand WireMock used to ship with a custom self-signed which was used when setting up https endpoints. Sice .NET Core 3 it relies on the dev certificate created by the SDK toolkit.
My question is whether it is possible to override this configuration a use a custom ssl certificate from a file.
My use-case is for example is CI. We run some builds on build agents but not all of them are correctly configured with the dev certificate. So some of the unit tests can fail. I would like to be able to remove the dependency on the environment and be able to configure the SSL certificate from a file - since importing to cert store is out of the question on the build agent.
Is there some settings I am overlooking?
Thank you for your time and an awesome nuget!
Hello @adusak, are you running WireMock.Net as C# in your unit-tests? Or do you use a separate Docker instance?
Hey, I am using it in C# unit tests.
Hi @adusak,
I've created a fix based on this article: https://devblogs.microsoft.com/aspnet/configuring-https-in-asp-net-core-across-different-platforms/
I've added a new property CertificateSettings on the WireMockServerSettings class.
Sorry, please use MyGet version WireMock.Net.1.3.5-ci-13960.nupkg.
See : https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
Wow, nice! It works like a charm 🙂 I was actually thinking of doing a PR with something along those lines if the config was missing. Thanks!
If you install version WireMock.Net.1.3.5-ci-13964.nupkg : this one has an extra setting "X509StoreThumbprintOrSubjectName" which you can set if you like.
(https://github.com/WireMock-Net/WireMock.Net/blob/certificate/src/WireMock.Net/Settings/IWireMockCertificateSettings.cs#L25)
(needed in case you have multiple localhost certificates defined in your store)
See also https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#certificatesettings
@adusak Can you do a last final test ?
Tested with the WireMock.Net.1.3.5-ci-13964.nupkg version and it still works great!
Code is merged to master. A new official NuGet will be ready soon.