asp.net - 始终使用 Asp.net 身份加密

标签 asp.net asp.net-identity always-encrypted

我们正在尝试将 Sql 2016 的 Always Encrypted 功能与 Asp.net Identity 2.0 一起使用。当我们将客户的数据存储到 AspNetUsers 表时,我们需要对其进行加密。这是为了遵守 GDPR。我们在 PhoneNumber 和 Email 列上设置了 Always Encrpted。我们能够加密电话号码,但是当我们尝试加密电子邮件列时,帐户 Controller 中的注册方法失败。当我们尝试注册时出现以下异常:

System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()", "InnerException": { "Message": "An error has occurred.", "ExceptionMessage": "Operand type clash: nvarchar(256) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'CEK_Auto1', column_encryption_key_database_name = 'StoreIdentityEF6AE') collation_name = 'Latin1_General_BIN2' is incompatible with varchar", "ExceptionType": "System.Data.SqlClient.SqlException",

有没有人遇到过这个问题并成功解决了?寻找一些使用 Asp.net Identity 加密客户数据的建议

最佳答案

我也曾为这个问题苦恼过,但我认为我已经找到了解决方案。

ASP.NET Identity 使用 UserStore:see implementation here

在那个 UserStore 中,一些方法使用了 ToUpper 方法。 您的电子邮件列已加密,因此 ToUpper 方法无法使用。它无法创建包含 SQL ToUpper 逻辑的查询。

我们所做的是构建 IUserStore 的自定义实现,并从对 EmailAddress 的查询中移除 ToUpper。

关于asp.net - 始终使用 Asp.net 身份加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48351737/

相关文章:

asp.net - 在哪里可以找到 ASP.NET Identity RC1 的文档?

sql-server - 始终加密、LINQ 以及包含位置

java - 更改加密 key 后,适用于 Java 的 Microsoft JDBC 驱动程序无法找到 Azure Always Encrypted 列加密 key

asp.net - 如何让旧的 VBScript ASP sendemail 在 Azure 上运行?

c# - 何时连接事件处理程序 asp.net

c# - 从 .net Framework 4.7.2 中的 base64 字符串创建证书请求

asp.net-core - 如何在配置文件更新后从 Identity Server 4 刷新声明?

c# - 如何覆盖 ASP.NET Core Identity 的密码策略

azure - SQL Server 2016 中始终加密的行为

asp.net - 使用模型 View 演示者设计模式的安全性和角色授权