Skip to content

Bogus "The target principal name is incorrect" on connecting to "." #4228

@jhudsoncedaron

Description

@jhudsoncedaron

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    Status

    Investigating

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions