Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to SQL Azure Database fails due to missing SSL encryption

I am learning ASP.NET 5 (vNext) on my Mac. For the last day, I've been stuck trying to connect to my SQL Azure database. In that attempt, I've been using the following code:

var serverName = "[protected]";
var dbName = "[protected]";
var userId = "[protected]";
var password = "[protected]";
var sql = "SELECT * FROM Customer";

using (var database = new SqlConnection("Server=tcp." + serverName + ".database.windows.net,1433;Database=" + dbName + ";User Id=" + userId + ";Password=" + password + ";Trusted_Connection=False;Encrypt=True;Max Pool Size=25"))
{
  database.Open();
  return await database.QueryAsync<T>(sql);                     
}

When this code gets executed, an exception is thrown. The exception details looks like this:

Type:
System.NotImplementedException

Message:
SSL encryption for data sent between client and server is not implemented.

UPDATE I learned that encryption isn't supported in the framework running on Mac OS X at this time. For that reason, I updated my connection string to looks like the following:

var connectionString = "Persist Security Info=False;Integrated Security=true;Initial Catalog=" + dbName + ";server=" + serverName + ";User Id=" + userId + ";Password=" + password;

Still, when I use the connection string above, I get the following error.

Type:
System.Data.SqlClient.SqlException

Message:
Server does not exist or connection refused.

I have confirmed that my IP address is not blocked by Azure. I did this by logging into the Azure Portal and managing the SQL Server database from the Silverlight app. Yet, I'm still not sure why I'm getting this error.

If I am understanding this correctly, there is not a way to connect to a SQL Azure database at this time from ASP.NET 5 running on a Mac. Is that true? If it is not true, what am I doing wrong?

like image 968
Some User Avatar asked May 28 '15 12:05

Some User


People also ask

Is Azure SQL connection encrypted?

SQL Database, SQL Managed Instance, and Azure Synapse Analytics enforce encryption (SSL/TLS) at all times for all connections. This ensures all data is encrypted "in transit" between the client and server irrespective of the setting of Encrypt or TrustServerCertificate in the connection string.

How do I change the TLS version on Azure SQL Server?

In the Azure portal, go to your SQL server resource. Under the Security settings, select Networking and then choose the Connectivity tab. Select the Minimum TLS Version desired for all databases associated with the server, and select Save. It's possible to change the minimum TLS version by using Azure PowerShell.

How can I tell if SQL Server SSL is enabled?

To identify if SQL SERVER database is SSL enabled or not, run the following query: "SELECT session_id, encrypt_option FROM sys. dm_exec_connections". It should be run by Database Administrator.


2 Answers

As you are aware vNext on Mac is under public preview.
We are still working on providing SQL connectivity. SSL encryption is not supported on Mac yet and Azure SQL DB requires one. The project is in the pipeline and we will let you know once we have something to share.
In the meanwhile if you have any other questions please let me know.

Best,
Meet Bhagdev
Program Manager, Microsoft

like image 115
meet-bhagdev Avatar answered Oct 07 '22 15:10

meet-bhagdev


Switch to using mono as a build target. This should give you access to ssl in entity framework.

like image 28
linkerro Avatar answered Oct 07 '22 13:10

linkerro