Exemple #1
0
        /// <summary>
        /// Fetches a certificate from a KeyVault, using an Actve Directory client and secret.
        /// </summary>
        /// <param name="accessTokenClientId">Required Ad client.</param>
        /// <param name="accessTokenClientSecret">Required Ad secret.</param>
        /// <returns>Not null.</returns>
        public static KeyVaultClient GetKeyVaultClient(
            string accessTokenClientId,
            SecureString accessTokenClientSecret)
        {
            ClientSecretAccessTokenHandler tokenHandler
                = new ClientSecretAccessTokenHandler(
                      accessTokenClientId,
                      accessTokenClientSecret);

            return(new KeyVaultClient(tokenHandler.GetToken));
        }
Exemple #2
0
 /// <summary>
 /// Fetches a certificate from a KeyVault, using an Actve Directory client and secret.
 /// </summary>
 /// <param name="accessTokenClientId">Required Ad client.</param>
 /// <param name="accessTokenClientSecret">Required Ad secret.</param>
 /// <param name="keyVaultBaseUri">Required KeyStore Uri.</param>
 /// <param name="certifcateName">Required certificate name.</param>
 /// <param name="cancellationToken">Optional</param>
 /// <returns>Not null.</returns>
 public static async Task <CertificateBundle> GetCertificate(
     string accessTokenClientId,
     SecureString accessTokenClientSecret,
     string keyVaultBaseUri,
     string certifcateName,
     CancellationToken cancellationToken = default)
 {
     using (ClientSecretAccessTokenHandler tokenHandler
                = new ClientSecretAccessTokenHandler(
                      accessTokenClientId,
                      accessTokenClientSecret)) {
         return(await new KeyVaultClient(tokenHandler.GetToken).GetCertificateAsync(
                    keyVaultBaseUri,
                    certifcateName,
                    cancellationToken));
     }
 }
Exemple #3
0
 /// <summary>
 /// Fetches a certificate from a KeyVault, using an Actve Directory client and secret.
 /// </summary>
 /// <param name="accessTokenClientId">Required Ad client.</param>
 /// <param name="accessTokenClientSecret">Required Ad secret.</param>
 /// <param name="vaultBaseUri">Required KeyStore Uri.</param>
 /// <param name="secretName">Required certificate name.</param>
 /// <param name="cancellationToken">Optional</param>
 /// <returns>Not null.</returns>
 public static async Task <SecretBundle> GetSecret(
     string accessTokenClientId,
     SecureString accessTokenClientSecret,
     string vaultBaseUri,
     string secretName,
     CancellationToken cancellationToken = default)
 {
     using (ClientSecretAccessTokenHandler tokenHandler
                = new ClientSecretAccessTokenHandler(
                      accessTokenClientId,
                      accessTokenClientSecret)) {
         return(await new KeyVaultClient(tokenHandler.GetToken).GetSecretAsync(
                    vaultBaseUri,
                    secretName,
                    cancellationToken));
     }
 }