2017-04-21 5 views

答えて

1

Key Vaultがシナリオに適したソリューションであるかどうかを検討する必要があります。公開鍵(本質的に)は機密データではなく、安全な場所に保管する必要はありません。汎用ストレージサービスを使用することができます。

キー・ボールトを使用する必要がある場合は、秘密鍵として保管することができます。鍵ボールトの秘密は、最大サイズがそれぞれ25kバイトのオクテットシーケンスです。

1

は、公開鍵証明書をロード

Azure Key Vault Explorerあなたは、公開鍵証明書(.cerのファイル)を読み込むことができます。

証明書は、そのアプリケーションで使用される「標準」形式を使用してキーボルトにキーとして格納されます(.cerファイルはAzure Key Vaultによってネイティブにサポートされていないため)。次のように公開鍵証明書にアクセスする

Example public key cert as stored by Azure Key Vault Explorer

あなたはAzureのキーボールトに公開鍵をロードした後

、彼らはその後、プログラム的にアクセスすることができます。

// load certificate based on format used by `Azure Key Vault Explorer` 
var azureServiceTokenProvider = new AzureServiceTokenProvider(); 
var kv = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback)); 
var certBundle = await kv.GetSecretAsync(secretIdentifier).ConfigureAwait(false); 

byte[] certBytes = null; 
if (certBundle.ContentType == "application/x-pkcs12") 
{ 
    certBytes = Convert.FromBase64String(certBundle.Value); 
} 
else if (certBundle.ContentType == "application/pkix-cert") 
{ 
    certBytes = certBundle?.Value.FromJson<PublicKeyCertificate>()?.Data; 
} 
if (certBytes != null && certBytes.Length > 0) 
{ 
    return new X509Certificate2(certBytes, 
     "", 
     X509KeyStorageFlags.Exportable | 
     X509KeyStorageFlags.MachineKeySet | 
     X509KeyStorageFlags.PersistKeySet); 
} 
return null; 

... 

// class used to access public key certificate stored in Key Vault 
public class PublicKeyCertificate 
{ 
    public byte[] Data; 
} 
関連する問題