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

Server certificate validation #194

Merged
merged 7 commits into from
Sep 4, 2018

Conversation

zivillian
Copy link
Contributor

fixes #192

@CLAassistant
Copy link

CLAassistant commented Jul 31, 2018

CLA assistant check
All committers have signed the CLA.

/// Disable any certificate validation. Do not use this in production.
/// </summary>
/// <param name="config"></param>
[Obsolete("This will open the client to Man-in-Middle attacks. It should never be used in production.")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this should be obsolete, I think this still needs to be the default behavior and we update the configuration guide on how to better handle this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I will not change this. I just don't want my name next to an insecure default. If someone needs to troubleshoot the integration, there is this default implementation for things like testing or just getting it to run locally, but this must not be used in production without even thinking about the consequences.
If some user really has the requirement and a good justification he may use this method and supress the warning, or just implement his own version of I don't care.
I know this will be a breaking change and should be mentioned clearly in the release notes.

Copy link
Member

@ejsmith ejsmith Aug 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We literally DO NOT have a choice in the matter. We can't use this in the default client because the cert will eventually expire and all deployed clients will all of a sudden not be able to submit events. It is not an option for us to go and tell users to update all of their software that makes use of the Exceptionless client whenever our SSL cert expires.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All clients using exceptionless.io have no problem as long as exceptionless.io has a valid certificate (which it should).
All of these extension methods are more or less dirty workarounds for users who a hosting their own exceptionless without a valid (or otherwise trusted) certificate.
Since exceptions may always contain sensitive and security critical data, I think running your own exceptionless instance without a proper sense of security should not be supported in any way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh. I guess I was thinking about the thumbprint setting. The default would do normal trusted root certificate validation and this is just for people to use a self-signed cert. Sorry for the confusion.

//handler.ServerCertificateCustomValidationCallback = delegate { return true; };
var callback = config.ServerCertificateValidationCallback;
if (callback != null) {
#if NET45
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this into dedicated methods. I know local functions are compiler sugar but it can cause runtime issues on say unmatched windows 7 machines (at least that's what I've found with other c# new features).

return callback(certData);
}

handler.ServerCertificateCustomValidationCallback = Validate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to be very careful here. Can you see if the supported flag was added here (https://github.com/dotnet/corefx/issues/9728). Please see this thread for more information on why this has been dangerous on non full framework.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed with 2.1 as curl was replaced by SocketsHttpHandler (https://blogs.msdn.microsoft.com/dotnet/2018/04/11/announcing-net-core-2-1-preview-2/#user-content-sockets-performance-and-socketshttphandler). I'm unsure how to detect this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our clients are compiled for .net Standard 1.2 and above, we can't guarantee that our clients are running 2.1 and need to be safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handler will only be installed if the user used one of the extension methods or implemented his own callback. Since this is currently also not supported for netcore version relying on curl this will not break anything.
I guess it should be mentioned in the release notes that there may be a problem with mac or linux on older netcore versions, but I think there is nothing you or I can do about this bug.
The previous implementation also required valid certificates on curl based netcore, so the behaviour is the same.

@@ -167,6 +157,20 @@ public class DefaultSubmissionClient : ISubmissionClient, IDisposable {
return client;
}

#if !PORTABLE && !NETSTANDARD1_2
#if NET45
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just do this for net45 and NETSTANDARD 2_0 as <2.0 might be on core 1.1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you tell me why? What is so special about core 1.1, that this feature should not be available?
The API is available from netstandard 1.3, supported since core 1.0 and hasn't changed since.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's part of the api in .net core 1.1 but broken in the runtime and this will cause all kinds of issues on non windows machines. We need to only include this on full framework or net standard 2.0 builds. If you could make this change that would be greatly appreciated and we could continue with merging this change in. I'm starting to work on testing for the next release and this could still make it in.

@niemyjski
Copy link
Member

Looks good, lets only include these changes on NET45 and .NET Standard 2.0

@niemyjski niemyjski merged commit 96858ed into exceptionless:master Sep 4, 2018
@niemyjski
Copy link
Member

Thanks for the PR

@niemyjski
Copy link
Member

were going to update our requirements on .net core 1.0 on plat and accept this change as is. Thanks for the pr and work for us. v4.3.1 is going to roll out shortly.

@zivillian zivillian deleted the cert_validation branch September 4, 2018 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Certificate is not validated in NET45
4 participants