How to create a Private Key, CSR and Import Certificate on Microsoft Azure KeyVault (Cloud HSM)

Article Number: 000070629

User-added image
Purpose: How to create a Private Key, CSR and Import Certificate on Microsoft Azure KeyVault (Cloud HSM)

Requirements
1. You must have an active Microsoft Azure account.
2. You must have selected either the Free or HSM (paid) subscription option. These steps will work for either Microsoft Azure account type.
3. Microsoft Azure PowerShell must be installed. You can download it here.

The solution is in three parts:
1) Creating the Private Key
2) Generating the Certificate Signing Request (CSR)
3) Importing the Public Signed Certificate to Microsoft Azure KeyVault

Part 1 of 3: Creating the Private Key

1. Launch Microsoft Azure PowerShell.

2. Log in to your Microsoft Azure account by typing:

Login-AzureRmAccount

You will be prompted to enter your credentials to log in to your account. Once you login successfully you will see something like the below:

3. Determine your Resource Group. If you already have an existing Resource Group, you can skip this step. Otherwise, to create a resource group you need to provide the pieces of information shown below:

 Entity Description 
 Resource Group Name This is the name you choose for your Resource Group. 
 Location Geographic location for your key. 

To create a new resource group, use the command below (please note to replace information enclosed in < > with your own):

New-AzureRMResourceGroup -Name '<Resource Group Name>' -Location '<Location>'

4. Determine your keyvault. If you do not have an existing keyvault, you will need to generate one. To create a new keyvault follow the command line below:

New-AzureRmKeyVault -VaultName '<your Vault Name>' -ResourceGroupName '<your Group Name>' -Location '<your Location>' -SKU 'Premium'

Where:

 Entity Description 
VaultName Your own Vault Name. This name is unique. Microsoft Azure will reject your Vault Name if someone else has already registered that name in the Cloud.
ResourceGroupName Your own Group Name (chosen in Step 3).
Location Geographic location for your key.

5. Create a private key. Please note that you can create multiple private keys in one keyvault. The command to create a key is (please note to replace information enclosed in < > with your own):

$key = Add-AzureKeyVaultKey -VaultName '<your Vault Name>' -Name '<your Private Key Name>' -Destination '<HSM/Software>'

Where:

 Entity Description 
VaultName Your Vault Name (chosen in Step 4).
Name Your Private Key Name.
Destination Location where you want to save your private key.

Your private key has been generated.

To view your private key inside your KeyVault, you can use the command (please note to replace information enclosed in < > with your own):

Get-AzureKeyVaultKey -VaultName '<YourVaultName>'
 

Part 2 of 3: Generating the Certificate Signing Request (CSR)

The Certificate Signing Request (CSR) will be generating from within Microsoft Azure KeyVault as follows:
1. Set the parameters for your certificate policy by using the following commands (please note to replace information enclosed in < > with your own):

$vaultName = '<your Vault Name>'
$certificateName = '<your Certificate Name>'

$manualPolicy = New-AzureKeyVaultCertificatePolicy -SubjectName "<your FQDN>" -ValidityInMonths 24 -IssuerName Unknown

Where:

 Entity Description 
$vaultName Your Vault Name.
$CertificateName Your own designated Certificate Friendly Name.
-subjectName Your Fully Qualified Domain Name (FQDN).

2. Execute the Certificate Operation Command:

$certificateOperation = Add-AzureKeyVaultCertificate -VaultName $vaultName -Name $certificateName -CertificatePolicy $manualPolicy

3. Generate Certificate Signing Request (CSR):

$certificateOperation.CertificateSigningRequest

You have successfully created the CSR and are ready to create the certificate. 
 

Part 3 of 3: Importing the Public Signed Certificate to Microsoft Azure KeyVault

Follow these steps to successfully import the Public Signed Certificate to Microsoft Azure KeyVault:

1. Download your certificate.

2. Unzip the file and store it to your local drive so you may import it to Microsoft Azure Keyvault.

3. Import the certificate to Microsoft Azure KeyVault using the command:

Import-AzureKeyVaultCertificate -VaultName $vaultName -Name $certificateName -FilePath 

Where:

 Entity Description 
$VaultName Your Vault Name.
$CertificateName Your Certificate Friendly Name
FilePath Location in your drive where you store your downloaded certificate file.

You have successfully imported your certificate into your Microsoft Azure KeyVault Cloud HSM.

If you have any questions or concerns please contact the AffirmTrust department for further assistance: 

Support Hours of Operation: 
Sunday 8PM ET to Friday 8PM ET
[email protected]