简体   繁体   English

由于缺少SSL加密,连接到SQL Azure数据库失败

[英]Connecting to SQL Azure Database fails due to missing SSL encryption

I am learning ASP.NET 5 (vNext) on my Mac. 我在Mac上学习ASP.NET 5(vNext)。 For the last day, I've been stuck trying to connect to my SQL Azure database. 在最后一天,我一直试图连接到我的SQL Azure数据库。 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 System.NotImplementedException

Message: 信息:
SSL encryption for data sent between client and server is not implemented. 未实现客户端和服务器之间发送的数据的SSL加密。

UPDATE I learned that encryption isn't supported in the framework running on Mac OS X at this time. 更新我了解到目前在Mac OS X上运行的框架中不支持加密。 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 System.Data.SqlClient.SqlException

Message: 信息:
Server does not exist or connection refused. 服务器不存在或连接被拒绝。

I have confirmed that my IP address is not blocked by Azure. 我已确认我的IP地址未被Azure阻止。 I did this by logging into the Azure Portal and managing the SQL Server database from the Silverlight app. 我通过登录Azure门户并从Silverlight应用程序管理SQL Server数据库来完成此操作。 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. 如果我正确理解这一点,那么目前无法从运行在Mac上的ASP.NET 5连接到SQL Azure数据库。 Is that true? 真的吗? If it is not true, what am I doing wrong? 如果不是这样,我做错了什么?

As you are aware vNext on Mac is under public preview. 如您所知,Mac上的vNext正在进行公开预览。
We are still working on providing SQL connectivity. 我们仍在努力提供SQL连接。 SSL encryption is not supported on Mac yet and Azure SQL DB requires one. Mac上不支持SSL加密,Azure SQL DB需要SSL加密。 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 认识Bhagdev
Program Manager, Microsoft 微软项目经理

Switch to using mono as a build target. 切换到使用mono作为构建目标。 This should give you access to ssl in entity framework. 这应该允许您访问实体框架中的ssl。

I know this isn't the answer you are looking for, but SQL Azure requires SSL per https://msdn.microsoft.com/en-us/library/azure/ff394108.aspx . 我知道这不是您正在寻找的答案,但SQL Azure 需要 SSL每个https://msdn.microsoft.com/en-us/library/azure/ff394108.aspx

I am pretty sure you are stuck until SSL support is added to OS X (either via Mono or CoreCLR). 我非常确定在OS X(通过Mono或CoreCLR)添加SSL支持之前,您会陷入困境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM