1

我正在尝试通过 API KeyVaultClient.CreateKeyAsync在Azure Key Vault中创建一个新密钥:

public Task<KeyBundle> CreateKeyAsync (
    string vaultAddress,
    string keyType,
    KeyAttributes keyAttributes)

文档keyType是:

要创建的密钥类型(有效的 WebKeyTypes 之一)

什么是有效的 WebKeyTypes?


我搜索了 MSDN 文档并没有找到任何东西。Powershell调用似乎不需要这个参数??:

Parameter Set: Create
Add-AzureKeyVaultKey 
          [-VaultName] <String> 
          [-Name] <String> 
          -Destination <String> {HSM | Software} 
          [-Disable] 
          [-Expires <DateTime]> ] 
          [-KeyOps <String[]> ] 
          [-NotBefore <DateTime]> ] 
          [-Tags <System.Collections.Hashtable> ] 
          [ <CommonParameters>]
4

3 回答 3

2

查看源代码Azure KeyVault SDK on Github,我唯一能找到的是JsonWebKeyTypes. 根据源代码,以下是可能的值:

public const string EllipticCurve = "EC";
public const string Rsa           = "RSA";
public const string RsaHsm        = "RSA-HSM";
public const string Octet         = "oct";

但是看着REST API documentation,我被引导相信只有RSA并且RSA-HSM目前受到支持。

于 2016-06-14T07:47:32.393 回答
1

它实际上记录在Key Vault MSDN 页面

初始 Azure Key Vault 版本仅支持 RSA 密钥;未来的版本可能支持其他关键类型,例如对称和椭圆曲线。

  • RSA:2048 位 RSA 密钥。这是一个“软”密钥,由 Key Vault 在软件中处理,但使用 HSM 中的系统密钥加密存储。客户端可以导入现有的 RSA 密钥或请求 Azure Key Vault 生成一个。
  • RSA-HSM:在 HSM 中处理的 RSA 密钥。RSA-HSM 密钥在 Azure Key Vault HSM 安全世界之一中受到保护(每个地理位置都有一个安全世界以保持隔离)。客户端可以以软形式或通过从兼容的 HSM 设备导出来导入 RSA 密钥,或者请求 Azure Key Vault 生成一个。此密钥类型将 T 属性添加到 JWK 获取以携带 HSM 密钥材料。

在撰写本文时,Key Vault 不支持 EC 和 oct 密钥。

于 2016-07-02T09:27:14.700 回答
0

拆卸后Microsoft.Azure.KeyVault.dll看起来像这样的KeyTypesCreateKeyAsync想要:

/// <summary>Supported JsonWebKey key types (kty)</summary>
public static class JsonWebKeyType
{    
   public const string EllipticCurve = "EC";
   public const string Rsa = "RSA";
   public const string RsaHsm = "RSA-HSM";
   public const string Octet = "oct";    
}

我尝试使用JsonWebKeyType.Octet,现在我收到一个新错误,但这是一个新问题。

于 2016-06-14T07:40:43.107 回答