标签: always-encrypted

管理员是否可以使用SQL Server 2016始终加密的功能查看加密数据?

这看起来是一个非常好的功能,但我明白它只有应用程序可以看到列的未加密文本,对吧?

带有SQL查询的管理员是否可以看到未加密的数据?或者它必须始终来自应用程序?

如果是,您可以发布一个小查询来显示此信息

sql sql-server sql-server-2016 always-encrypted

4
推荐指数
1
解决办法
681
查看次数

SQL Server 2016 Express是否支持始终加密?

SQL Server 2016的Express版本中是否提供SQL Server的新加密"静止和运动"功能?

.net sql-server sql-server-express sql-server-2016 always-encrypted

4
推荐指数
2
解决办法
2717
查看次数

操作数类型冲突:varchar 与尝试插入加密数据库的 varchar(50) 不兼容

我得到一个SqlException

操作数类型冲突:varchar 与使用加密的 varchar(50) 不兼容 (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_name_1L_General encryption_property_key_database_1Latinr_Inc.从客户端收到元数据。该错误发生在批处理调用期间,因此客户端可以通过调用 sp_describe_parameter_encryption 刷新参数加密元数据并重试。

我的 C# 代码:

using (var connection = new SqlConnection(GetConnectionString()))
{
    using (var cmd = new SqlCommand("Clients_Insert", connection))
    {
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add("@Email", SqlDbType.VarChar, 50).Value = client.Email;
        cmd.Parameters.Add("@ContactPerson", SqlDbType.VarChar, 400).Value = client.ContactPerson;

        connection.Open();
        cmd.ExecuteNonQuery();
    }
}
Run Code Online (Sandbox Code Playgroud)

还有我的存储过程:

ALTER PROCEDURE [dbo].[Clients_Insert]
    @Email VARCHAR(50),
    @ContactPerson VARCHAR(400)
AS
BEGIN
    INSERT into dbo.Clients(Email, ContactPerson) 
    VALUES (@Email, @ContactPerson);

    SELECT SCOPE_IDENTITY();
END;
Run Code Online (Sandbox Code Playgroud)

我将数据插入未加密的字段没有问题。

我找到了这篇文章

http://dataap.org/sql-2016-ctp/column-level-encryption-using-always-encrypted-in-sql-server-2016/

我的问题是类似的,但我还没有找到解决方案。

c# sql-server asp.net encryption always-encrypted

4
推荐指数
2
解决办法
2万
查看次数

How to read SQL Always-encrypted column from classic ASP

I maintain a classic ASP app (yeah, I know, we're working on it) and need to access Always Encrypted columns in SQL 2017.

I've imported the cert and tested in SSMS and PowerShell and that much works. The best I've been able to do in ASP is to get the encrypted value as a byte array. I've tried more connection string combinations than I can remember. My ASP dev box is Windows 10; the data server is SQL 2017.

cnn …
Run Code Online (Sandbox Code Playgroud)

sql-server asp-classic always-encrypted

4
推荐指数
1
解决办法
1150
查看次数

如何在 SQL Server Always Encrypted 列上使用 Like 运算符?

请帮助我修复 SQL Sever 2016 中的以下查询,其中列 FIRST_NAME、LAST_NAME 始终是加密的。

SELECT * FROM MY_TABLE
WHERE (LAST_NAME LIKE '%[@,#,$,%,*]%' OR LAST_NAME LIKE '%,%')
OR (FIRST_NAME LIKE '%[@,#,$,%,*]%' OR FIRST_NAME LIKE '%,%');
Run Code Online (Sandbox Code Playgroud)

我收到以下错误,因为列始终是加密的,而且我无法声明变量并将字符串分配给它。

Msg 206, Level 16, State 2, Line 1
Operand type clash: varchar(50) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_POC_CERTSTORE', column_encryption_key_database_name = 'UIM-LOCAL-DB') collation_name = 'Latin1_General_BIN2' is incompatible with varchar
Run Code Online (Sandbox Code Playgroud)

sql-server encryption sql-server-2016 always-encrypted

2
推荐指数
1
解决办法
4257
查看次数

SQL Server SSL + TDE 与始终加密

使用 SQL Server SSL(连接字符串中的 Encrypted=true)+ TDE 与使用 SQL Server Always Encrypted 有什么区别?

关于 RGPD,一个比另一个更适应吗?

sql-server ssl tde always-encrypted

2
推荐指数
1
解决办法
1394
查看次数

.NET Core 3.1 始终加密

使用 .NET Core 3.1 和 SQL Always Encrypted 时出现以下错误。3.1支持这个吗?也许我在这里遗漏了一些东西..

Keyword not supported: 'column encryption setting'.
Run Code Online (Sandbox Code Playgroud)

目前已安装以下软件包

    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.12.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="Dapper" Version="2.0.30" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" Version="1.0.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.1" />
    <PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
    <PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
    <PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
    <PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="3.0.4" />
    <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
Run Code Online (Sandbox Code Playgroud)

always-encrypted .net-core-3.1 asp.net-core-3.1

2
推荐指数
1
解决办法
4771
查看次数

通过具有 MFA(Active Directory 交互)的 PowerShell 对 SQL Server 进行身份验证

我正在尝试设置一个 PowerShell 脚本以在我们的 Azure SQL Server 数据库上启用始终加密。我正在遵循本指南,其中提供了以下示例代码:

# Import the SqlServer module
Import-Module "SqlServer"  

# Connect to your database
# Set the valid server name, database name and authentication keywords in the connection string
$serverName = "<Azure SQL server name>.database.windows.net"
$databaseName = "<database name>"
$connStr = "Server = " + $serverName + "; Database = " + $databaseName + "; Authentication = Active Directory Integrated"
$database = Get-SqlDatabase -ConnectionString $connStr

# List column master keys for the specified …
Run Code Online (Sandbox Code Playgroud)

sql-server powershell azure-sql-database always-encrypted

2
推荐指数
1
解决办法
2729
查看次数

为什么我的应用用户找不到始终加密的证书?

使用 SQL Server 2017 我按照这篇文章应用了 Always Encrypt 技术:https : //www.codeproject.com/Articles/1110564/Always-Encrypted-feature-in-SQL-Server 简单地说:

  1. 创建列主密钥。
  2. 创建列加密密钥。
  3. 使用后者加密列。

用于步骤 1.的证书是使用向导生成的并保存在:
密钥库: Windows Certificate Store - Local Machine

我创建了一个非常简单的控制台应用程序,它使用 EF 尝试从我对列进行加密的表中获取数据。

我在连接字符串中添加了这个:column encryption setting=Enabled.

当我尝试获取数据时:

    using (MyEntities en = new MyEntities())
    {
        var x = en.TableHasColEnc.ToList();
    }
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

'未能解密列'X'。无法使用密钥存储提供程序解密列加密密钥:“MSSQL_CERTIFICATE_STORE”。加密列加密密钥的最后 10 个字节是:'XX-XX-XX-XX-XX-XX-XX-XX-XX-XX'。在证书位置“LocalMachine”的证书存储“My”中找不到带有指纹“...”的证书。验证数据库中列主密钥定义中的证书路径是否正确,并且证书已正确导入到证书位置/存储中。参数名称:masterKeyPath'

我了解到运行此应用程序的用户无法访问该位置以获取证书,但为什么呢?
如果我以管理员身份运行该应用程序,它将正常工作。

我打开mmc并检查Certificates (Local Computer)并找到了在步骤 1 中使用的证书它看起来在本地机器中正确,而不是当前用户。

为什么我会收到此错误以及如何解决?

sql-server always-encrypted

1
推荐指数
1
解决办法
2254
查看次数

加密列上的模式匹配

即使在 SQL Server 2019 版本中,我也无法对加密列进行模式匹配。

SQL Server 2019

加密前

select * 
from messageencryption;     
Run Code Online (Sandbox Code Playgroud)

输出:

id    msgcode   msg      
-------------------------------------------
1      AA56B    this is a text message     
2      AA56C    this is a text123 message    
3      AA56D    EXTENDED BOOTCAMP      
4      AA56E    extended bootcamp       
5      AA56J    advance happy new year       
6      AA56K    oneteam       
7      AA56L    cricket team consists of 11 players       
8      AA56M    indian cricket team      

select * 
from messageencryption 
where msg like '%team%';       
Run Code Online (Sandbox Code Playgroud)

输出:

id   msgcode   msg              
----------------------------
6    AA56K     onesmallteam                   
7    AA56L …
Run Code Online (Sandbox Code Playgroud)

sql-server encryption always-encrypted

1
推荐指数
1
解决办法
574
查看次数

网络服务或 AppPool 帐户的始终加密证书

我正在尝试将 Always Encrypted 应用程序部署到 Amazon AWS。有一个 2016 RDS 数据库和一个托管 ASP.NET 4.6 应用程序的 Windows Server 2016。

在 Windows Server 上,当应用程序在网络服务或应用程序池标识下运行时,我们得到的正是我非常确定的问题

我们的错误:

System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out

  • 我们尝试了该帖子中的解决方案,但没有成功
  • 我们尝试了这篇文章中的解决方案,但无法让 powershell 脚本返回除运行时异常之外的任何内容。我对 powershell 不太熟悉,所以也许我不明白这个脚本。
  • 如果我们将证书导入到管理员帐户,并使用管理员帐户运行 IIS 应用程序池,则一切正常(不是连接问题或任何问题)
  • 我们尝试将证书导入本地计算机“个人”证书,并赋予应用程序帐户对密钥的完全控制权
  • 我们尝试将证书导入到本地计算机受信任的根证书颁发机构(如 as/o post 中的建议)。
  • 我们尝试为 DefaultAppPool 和 Network Service 帐户使用“runas”运行 certmgr,但是当提示输入密码时,我们不知道密码是什么(空白密码不起作用)。我什至按照此处的建议查找了 DefaultAppPool 密码,根据该输出,密码为空。

到目前为止,没有任何效果(除了以管理员身份运行应用程序之外),我们不知道下一步该尝试什么。我们到处寻找某种“微软官方部署指南”,但所有这些都是关于如何在本地开发环境中使始终加密工作的教程,而不是关于服务器部署。

sql-server iis sql-server-2016 always-encrypted

0
推荐指数
1
解决办法
1331
查看次数