Blog Post

Azure Database Support Blog
2 MIN READ

Lesson Learned #141: The target principal name is incorrect connecting to Azure SQL Database.

Jose_Manuel_Jurado's avatar
Oct 21, 2020

Today, I worked on an interesting service request where our customer tried to connect using the FQDN of their private link endpoint - servername.privatelink.database.windows.net and our customer got the error: Error 0 - The target principal name is incorrect. Why?

 

Here we have two issues to explain:

 

  • First of all, when you created a private link there is not needed to connect to the server using the FQDN private link, basically, you need to pay attention in how you have created the private link. If you enabled the Private DNS for a specific VNET and Subnet, you are going to have a new entry in your DNS with the new IP resolution of you Azure SQL Database servername.database.windows.net. If you didn't enable this private DNS or you didn't allow to update the DNS entry, the resolution will be the public IP. For this reason, it is very important to know this first thing. Please, always check the DNS resolution when you have enable a private endpoint. 
  • Second, when you establish the connection to Azure SQL Database, in order to encrypt the data, our gateway encryt this using the certificate that we have for the domain *.database.windows.net. For this reason, if you tried to connect servername.privatelink.database.windows.net you are going to have this error message about "Error 0 - The target principal name is incorrect" if you want to skip this validation, basically you need to specify in your connection string the parameter "Trust Server Certificate" and you would be able to connect. But, my recomendation is always use the servername.database.windows.net and configure correctly your DNS to prevent any additional problem.

 

Enjoy

Published Oct 21, 2020
Version 1.0

2 Comments

  • George_Barsi's avatar
    George_Barsi
    Copper Contributor

    This is an old subject but a new problem for me once I changed my DNS forwarders to only forward privatelink.database.windows.net to the Azure Private DNS Resolver.  That said I get the private IP address when I query privatelink.database.windows.net and the external IP address (external is blocked for my sql database servers) when I query the database.windows.net.

     

    This was required as we use other (3rd Party) applications that use Microsoft resources, and we need to ensure that non-privatelink dns calls resolve to the internet addressable IP address.  When we had database.windows.net as the DNS forwarder domain the Azure Private DNS would not resolve the IP address of 3rd parties Microsoft SAS resources at all.

     

     

    Given all of this is there some new way to address this privatelink challenge SSL trust challenge?

     

    Thank you!

     

  • Armando_64's avatar
    Armando_64
    Copper Contributor

    You Right!

     

    In my case the Private DNS :  privatelink.database.windows.net had a bad "Virtual network links"  settings(wrong v-net)

     

    Thanks.