Skip to content

How to diagnose certificate validation error? #2032

@wokket

Description

@wokket

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions