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

Add hook to perform custom server certificate validation #1074

Open
philchuang opened this issue Mar 21, 2019 · 1 comment
Open

Add hook to perform custom server certificate validation #1074

philchuang opened this issue Mar 21, 2019 · 1 comment

Comments

@philchuang
Copy link

I'm getting the exception "The remote certificate is invalid according to the validation procedure." which is thrown from MetadataLoader.cs:93.

Our Azure App Service is trying to access a site over HTTPS which does not use the standard root certs, so when the WebClient.Open call is made, it tries to validate the server's certificates and then throws an exception.

Unfortunately there is no way to add root certificates to Azure App Services, you can only add certs to CurrentUser/My.

In .NET framework, you can implement your own custom server certificate method by adding a delegate to ServicePointManager.ServerCertificateValidationCallback, which globally handles all client requests.

But in dotnet core, you can't do this globally, you have to supply a delegate to HttpClientHandler.ServerCertificateCustomValidationCallback.

So this request is for:

  1. Change MetadataLoader to use HttpClient (HttpMessageHandler) instead of WebClient()
  2. Add in a hook so that the implementing code can modify the HttpClientHandler before HttpClient.GetAsync()
@AndersAbel
Copy link
Member

Thanks for pointing out the changes in .NET Core. The entire MetadataLoader is up for a redesign, so I'll keep this in mind when doing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants