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

How to diagnose certificate validation error? #2032

Closed
wokket opened this issue May 8, 2023 · 2 comments
Closed

How to diagnose certificate validation error? #2032

wokket opened this issue May 8, 2023 · 2 comments

Comments

@wokket
Copy link

wokket commented May 8, 2023

We have a Sql Server that we connect to from an azure hosted docker container (Alpine .net 7, SqlClient 5.1.0).

We've previously used TrustServerCertificate=true to bypass the fact we connect via an IP (of a firewall or gateway or something) from azure which obviously name mismatches the cert issued by an internal CA.

With the addition of HostNameInCertificate we're now trying to remove the TrustServerCertificate from the connection string, but receive the following error:

Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)
 ---> System.Security.Authentication.AuthenticationException: The remote certificate was rejected by the provided RemoteCertificateValidationCallback.

While this is clearly a cert validation issue, we get no information about why the certificate failed, and an afternoon of searching has given me no leads (A simple server name typo in the conn string? Incorrectly installed root cert in the docker container? Unable to access CRL url? Who knows?), hence this question.

Can anyone provide guidance on diagnosing cert validation errors from SqlClient, particularly when occurring inside a linux docker image on Azure App Service?

@JRahnama
Copy link
Contributor

JRahnama commented May 9, 2023

@wokket we will get back to you with more info.

@JRahnama JRahnama added 🆕 Triage Needed For new issues, not triaged yet. and removed 🆕 Triage Needed For new issues, not triaged yet. labels May 9, 2023
@DavoudEshtehari
Copy link
Contributor

Proposed PR #2060 addressed this issue in the main branch. It'll be backported to 5.1 as well.

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

No branches or pull requests

3 participants