Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overriding the default ssl certificate via file. #536

Closed
adusak opened this issue Nov 6, 2020 · 10 comments
Closed

Overriding the default ssl certificate via file. #536

adusak opened this issue Nov 6, 2020 · 10 comments
Labels

Comments

@adusak
Copy link

adusak commented 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!

@adusak adusak added the question label Nov 6, 2020
@StefH
Copy link
Collaborator

StefH commented Nov 7, 2020

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

@adusak
Copy link
Author

adusak commented Nov 7, 2020

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

@StefH
Copy link
Collaborator

StefH commented 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
Copy link
Collaborator

StefH commented 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

@adusak
Copy link
Author

adusak commented 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!

@StefH
Copy link
Collaborator

StefH commented 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 StefH added feature and removed question labels Nov 8, 2020
@StefH
Copy link
Collaborator

StefH commented Nov 8, 2020

@StefH
Copy link
Collaborator

StefH commented Nov 10, 2020

@adusak Can you do a last final test ?

@adusak
Copy link
Author

adusak commented Nov 10, 2020

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

@StefH
Copy link
Collaborator

StefH commented Nov 10, 2020

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

@StefH StefH closed this as completed Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants