Certificate Issue While Connecting Azure Virtual Machine Database

If you are trying to connect to a SQL Server database which resides in Azure Windows Virtual Machine from SQL Server Management Studio and a .NET application .

We will explain those issues and share our experience on how you can solve these issues.

Issue 1 : When you tried to connect to Azure VM SQL Server from SQL Server Management Studio and If you get the following error and couldn’t connect to the database.

Solution :

Open SSMS and Click on the database connect option and provide server credentials. Then click on Options, as depicted below.

The below screen will appear. Select Trust Certificate and then Click on Connect option.

After that, You will be able to connect to Azure VM Database from SQL Server Management Studio. You have to mark the Trust server certificate options then only it allows you to connect to the server.

Issue 2- You were not able to connect to the Database from the Application even though you provided proper server details and parameters in the connection string.

Error :

“A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 — The certificate chain was issued by an authority that is not trusted.)”

Solution :

When you trying to connect to the Azure VM Database, you need to add the following part in the connection string.

“TrustServerCertificate=True”

Check whether or not there is a TrustServerCertificate available in your Webconfig. If not, then add this and make it True. If it is available and the value is False, then make it True.

The WebConfig file connection string should be as shown below:

<add key=”ConnectionString” value=”Server=serverName.xxx.cloudapp.azure.com;Initial Catalog=DatabaseName;Persist Security Info=False;User ID=UserId;Password=YourDBPassword;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=true;Connection Timeout=300000;” />

--

--

--

intforce software is software service company and providing complete IT solution with fresh perspective. https://intforcesoftware.com/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Gradle & Kotlin — create tests artifact

Data Structures-Elementary notes

Semantic HTML and Accessibility

Firebase Android Codelab

C# Namespaces

Why GraphQL Over REST

How to Start Using Django in 4 mins

Saving Images from a webcam feed frame by frame using OpenCV

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Intforce Software

Intforce Software

intforce software is software service company and providing complete IT solution with fresh perspective. https://intforcesoftware.com/

More from Medium

Create Azure Functions using Java, Maven and deploy on Azure Portal

Secure way to use Secrets with Java using Azure Key Vault and Managed Identity

https://makeameme.org/meme/someone-figured-out-c3fdc09613

Partitioning in Azure CosmosDB

Azure Bicep: Deploy Morpheus Data Appliance on Ubuntu 20.04LTS