LoginSignup
0
0

More than 1 year has passed since last update.

AuthenticationException: The remote certificate was rejected by the provided RemoteCertificateValidationCallback.

Last updated at Posted at 2022-09-27

SqlException: 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)

ADO.NETでSQLServerに接続を試みると、Errorとなった。

AuthenticationException: The remote certificate was rejected by the provided RemoteCertificateValidationCallback.

"リモート証明書は、提供された RemoteCertificateValidationCallback によって拒否されました。"
と表示された。

実行環境
  • .NET6
  • Microsoft.Data.SqlClient 5.0.0

Screen Shot 2022-09-27 at 4.00.41.png

RemoteCertificateValidationCallbackは、リモートSSL (Secure Sockets Layer) 証明書を検証してbooleanを返すメソッドだった。

DB接続文字列を修正

connectionStringに渡す接続文字列にTrustServerCertificate=Trueを追加した。
"TrustServerCertificate を true に設定した場合、トランスポート層に SSL が使用されてチャネルが暗号化されます"とのこと。

"Server={server};Database={database};User Id={id};Password={password};" +
"TrustServerCertificate=True;"

Reference

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0