Bogus "The target principal name is incorrect" on connecting to "."
- Dominant language
- C#
- Stars
- 989
- Forks
- 340
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 72
Description
### Describe the bug
With a connection string that reads "Server=.;Database=...", trying to connect to SQL Server with a fully valid certificate does not work.
If you are seeing an exception, include the full exceptions details (message and stack trace).
```
Microsoft.Data.SqlClient.SqlException
HResult=0x80131904
Message=A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The target principal name is incorrect.)
Source=Core Microsoft SqlClient Data Provider
StackTrace:
at Microsoft.Data.SqlClient.Connection.SqlConnectionInternal.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
Inner Exception 1:
Win32Exception: The target principal name is incorrect.
```
### To Reproduce
1) Have SQL Server
2) Have loaded SQL Certificate
### Expected behavior
Any certificate that is valid for the current hostname is valid for .
My certificate is issued for hostname.domain.name , hostname, and localhost. The certificate should pass.
### Further technical details
Microsoft.Data.SqlClient version: 7.0.0
.NET target: .NET 10
SQL Server version: SQL 16 (why? to load backup files from SQL 16 of course)
Operating system: Windows 11
**Additional context**
Changing . to localhost does work; assuming nobody tampered with DNS lookup for localhost. But I shouldn't have to depend on that. . exists as an alias for a reason.
It is not possible to issue a certificate for . as that will be interpreted as a certificate that's valid _for the root domain_.
Contributor guide
Assessment
This issue has not been assessed yet.