admin管理员组文章数量:1122832
I have a .NET Core website where I've replaced the deprecated System.Data.SqlClient library with Microsoft.Data.SqlClient, and can no longer connect to the default SQL Server instance on my server.
I was originally using Server=localhost in the connection string, but since changing library this brings up the error message
The certificate received from the remote server does not contain the expected name. It is therefore not possible to determine whether we are connecting to the correct server. The server name we were expecting is localhost. The TLS connection request has failed.
I have a wildcard certificate for *.mydomain.example
in place under SQL Server Configuration and 'Force Encryption' turned on, which was working fine, and still does for other sites using System.Data.SqlClient. Despite using localhost
I assume that the encryption was working as when the certificate periodically expired, the SQL connection would fail.
I've added an A record to my DNS server for server.mydomain.example
which points to 127.0.0.1, changed the connection string to Server=server.mydomain.example
and I no longer get the original error. Instead I get
Named Pipes Provider, error: 40 - Could not open a connection to SQL Server
I've also tried adding an entry to the hosts file but get the same issue.
If I force TCP (as Named Pipes is disabled anyway) with Server=TCP:server.mydomain.example
then I get
TCP Provider, error: 0 - The remote computer refused the network connection
Rolling back to the old library is the obvious fix, but I'd like to understand why it's not working.
本文标签: netCan39t connect to encrypted SQL Server connection using MicrosoftDataSqlClientStack Overflow
版权声明:本文标题:.net - Can't connect to encrypted SQL Server connection using Microsoft.Data.SqlClient - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736303043a1931748.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论