是否可以从 Azure Key Vault Keys 中获取私钥?

Is it possible to get the private key out of Azure Key Vault Keys?

我在 Azure Key Vault 中看到的所有数据 encryption/decryption 示例都在本地使用 keyVaultClient.DecryptAsync() 方法在 Azure 内部进行加密和解密。

我知道这样更安全,因为私钥永远不会离开 Azure 并泄漏到您的应用程序代码中,但是如果我也想在本地进行解密,我该如何取出私钥?

我正在使用 keyVaultClient.GetKeyAsync(),但它似乎只包含 public 键。

我在 Azure 解密中遇到的一个问题是,如果开发人员无法访问 Azure,我无法在开发环境中复制它。 Azure Key Vault 似乎没有模拟器。

看起来实现我想要的唯一方法是使用 Azure Key Vault Secret 并在其中存储包含 public/private 个密钥的 PFX 证书?

抱歉,没有。

Azure Key Vault does not support EXPORT operations:一旦在系统中配置了密钥,就无法提取或修改其密钥 material。

您可以进行备份,但只有恢复到 Azure 才有用。您不能在其他任何地方使用它。

正如 TerryCarmen 所说,您无法在本地解密只有 public 密钥可用于系统。 API 对 GetKeyAsync 的调用不会 return 私钥 data.This 是 DecryptAsync 包装器方法确实使用 Key Vault API 进行解密的原因。

换句话说,私钥永远不会离开保险库,这是使用 Key Vault 进行解密而不是将私钥带入过程的原因之一。

更多细节,你可以参考这个article