The thumbprint of same asymmetric key is not same in 'SQL Server Connector for Microsoft Azure Key Vault' 1.0.4.0 and 'SQL Server Connector for Microsoft Azure Key
https://support.microsoft.com/en-us/help/4470999/db-backup-problems-to-sql-server-connector-for-azure-1-0-5-0
A breaking change has been introduced in Version 1.0.5.0 of 'SQL Server Connector for Microsoft Azure Key Vault' . The 1.0.5.0 version updated the way it calculates thumbprints to match the logic used in the engine, in order to support the migration scenario of On Prem SQL Server using EKM to Azure SQL DB using TDE BYOK. Because of this change, customer may hit issues when they are trying to restore database backups from when they were using 1.0.4.0 or old version to a server using 1.0.5.0 version.
Here is an example
===
SQL Server instance sql1 has 'SQL Server Connector for Microsoft Azure Key Vault' 1.0.4.0 deployed. SQL Server instance sql2 has 'SQL Server Connector for Microsoft Azure Key Vault' 1.0.5.0 deployed. Both instance sql1 and sql2 deploy an ASYMMETRIC key from the same ASYMMETRIC key in Azure Key Vault.
CREATE ASYMMETRIC KEY TDE_KEY
FROM PROVIDER AzureKeyVaultProvider
WITH PROVIDER_KEY_NAME = 'key1',
CREATION_DISPOSITION = OPEN_EXISTING
The thumbprints are different. The length of thumbprint of 1.0.5.0 version is little bit greater than the thumbprint of 1.0.4.0 version.
Here is example of thumbprint of 1.0.4.0 version
0x2C5677D76F76D77F80
Here is example of thumbprint of 1.0.5.0 version. Please note, both asymmetric keys are created from same source.
0x373B314B78E8D59A0925494558FEF14B726216C5
This breaking change causes problem in backup/restore scenario.
For example, if you have a backup of a database encrypted by an asymmetric key in Azure Key vault in instance sql1.
The instance sql2 has same asymmetric key created.
If you try to restore the backup to instance sql2, the restore fails with the error message below
Msg 33111, Level 16, State 4, Line 20
Cannot find server asymmetric key with thumbprint '0x2C5677D76F76D77F80'.
Here is the query to retrieve the thumbprint of each key.
select thumbprint,* from master.sys.asymmetric_keys
Here is the query to retrieve the thumbprint of each TDE database
select db_name(ddek.database_id) as DatabaseName,ak.name as[Asymmetric key Name], ak.thumbprint From sys.dm_database_encryption_keys ddek inner join master.sys.asymmetric_keys ak on ak.thumbprint=ddek.encryptor_thumbprint
Solution
===
Copy the 'SQL Server Connector for Microsoft Azure Key Vault' 1.0.4.0 or related version to the instance sql2 box.
Run the query below in sql2 to change the CRYPTOGRAPHIC PROVIDER to 1.0.4.0 version.
ALTER CRYPTOGRAPHIC PROVIDER AzureKeyVaultProvider
FROM FILE =
'C:\Program Files\SQL Server Connector for Microsoft Azure Key Vault\1.0.4.0\Microsoft.AzureKeyVaultService.EKM.dll'
Create a new asymmetric key using the 1.0.4.0 provider.
CREATE ASYMMETRIC KEY TDE_KEY_1040
FROM PROVIDER AzureKeyVaultProvider
WITH PROVIDER_KEY_NAME = 'key1',
CREATION_DISPOSITION = OPEN_EXISTING
After that, you are able to restore the backup.
Run the query below in sql2 to revert the CRYPTOGRAPHIC PROVIDER to 1.0.5.0 version.
ALTER CRYPTOGRAPHIC PROVIDER AzureKeyVaultProvider
FROM FILE =
'C:\Program Files\SQL Server Connector for Microsoft Azure Key Vault\1.0.5.0\Microsoft.AzureKeyVaultService.EKM.dll'
You can either use the same asymmetric key or change to a new version asymmetric key to use the new thumbprint.
alter DATABASE ENCRYPTION KEY
ENCRYPTION BY SERVER ASYMMETRIC KEY KeyName1050Version
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
2007-01-26 微软推出wcf和wpf的HOL了吗