-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Trusting the self signed certificate to enable SSL on dotnet core #379
Comments
Do you only have this issue in .net core 3? |
No it appears in core 2.1/2.2 also. I think it because you are passing in a hardcoded cert Alternatively you could make the certificate public so that you can choose to trust it like this:
All of the above is untested but might work in theory |
I see your point. Currently I'm using a self-signed certificate in WireMock when using netstandard or net core. But, I can't remember why I created an own self-signed, and not just use the default development certificate like https://www.hanselman.com/blog/DevelopingLocallyWithASPNETCoreUnderHTTPSSSLAndSelfSignedCerts.aspx. So I think I need to update the current code to make it an option:
What do you think? |
My preference would be to follow the same defaults as kestrel, as that is what developers are most likely to be familiar with. This means the default should be to leave the cert blank and pick up the dev cert, and to host on 5001 by default if SSL is enabled and no port is specified. That way most users will find SSL just works and follows the idioms of regular aspnet development. Then I suggest we also allow the user to pass an wireMockSettings.ConfigureKestrel(serverOptions =>
{
//do some custom config here.
} We then hold the The options aspnet core/Kestrel allows are detailed at If you then make wireMockSettings.ConfigureKestrel(serverOptions =>
{
serverOptions.ConfigureHttpsDefaults(listenOptions =>
{
listenOptions.ServerCertificate = PublicCertificateHelper.GetX509Certificate2();
});
}); Although this seems like a breaking change, at the moment I can't see any way a way for wiremock users on dotnet core to use HTTPS without disabling all certificate validation anyway, so those users would not be affected. |
I'll follow default development certificate for .NET Core 2.x for now. Preview version from MyGet is |
@alastairtree Did this work for you? |
Yes it did, Thanks! |
Closing issue |
In the following code (tested running on dotnet core 3.0/2.2/2.1) I want to start a stub server with SSL enabled and then call it, and for that https call to be trusted and allowed. However, the self signed cert issued by wiremock is not trusted and the call fails with
AuthenticationException: The remote certificate is invalid according to the validation procedure
.I assumed that running on port 5001 would use the self signed kestral dev certs installed by default by the dotnet cli and so be trusted but I think not based on the below failing.
What is the easiest "out of the box" way to get SSL to work like in the example below?
Or is there a way to get wiremock to use a self siged cert I already trust or to get the current certificate out of the server so I can validate it easily in the client?
The text was updated successfully, but these errors were encountered: