Overriding the default ssl certificate via file. #313

Closed
opened 2025-12-29 08:25:57 +01:00 by adam · 10 comments
Owner

Originally created by @adusak on GitHub (Nov 6, 2020).

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!

Originally created by @adusak on GitHub (Nov 6, 2020). 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!
adam added the feature label 2025-12-29 08:25:57 +01:00
adam closed this issue 2025-12-29 08:25:57 +01:00
Author
Owner

@StefH commented on GitHub (Nov 7, 2020):

Hello @adusak, are you running WireMock.Net as C# in your unit-tests? Or do you use a separate Docker instance?

@StefH commented on GitHub (Nov 7, 2020): Hello @adusak, are you running WireMock.Net as C# in your unit-tests? Or do you use a separate Docker instance?
Author
Owner

@adusak commented on GitHub (Nov 7, 2020):

Hey, I am using it in C# unit tests.

@adusak commented on GitHub (Nov 7, 2020): Hey, I am using it in C# unit tests.
Author
Owner

@StefH commented on GitHub (Nov 7, 2020):

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.

@StefH commented on GitHub (Nov 7, 2020): 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.
Author
Owner

@StefH commented on GitHub (Nov 7, 2020):

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

@StefH commented on GitHub (Nov 7, 2020): 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
Author
Owner

@adusak commented on GitHub (Nov 7, 2020):

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!

@adusak commented on GitHub (Nov 7, 2020): 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!
Author
Owner

@StefH commented on GitHub (Nov 7, 2020):

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)

@StefH commented on GitHub (Nov 7, 2020): 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)
Author
Owner

@StefH commented on GitHub (Nov 8, 2020):

See also https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#certificatesettings

@StefH commented on GitHub (Nov 8, 2020): See also https://github.com/WireMock-Net/WireMock.Net/wiki/Settings#certificatesettings
Author
Owner

@StefH commented on GitHub (Nov 10, 2020):

@adusak Can you do a last final test ?

@StefH commented on GitHub (Nov 10, 2020): @adusak Can you do a last final test ?
Author
Owner

@adusak commented on GitHub (Nov 10, 2020):

Tested with the WireMock.Net.1.3.5-ci-13964.nupkg version and it still works great!

@adusak commented on GitHub (Nov 10, 2020): Tested with the `WireMock.Net.1.3.5-ci-13964.nupkg` version and it still works great!
Author
Owner

@StefH commented on GitHub (Nov 10, 2020):

Code is merged to master. A new official NuGet will be ready soon.

@StefH commented on GitHub (Nov 10, 2020): Code is merged to master. A new official NuGet will be ready soon.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#313