Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Announcing an easier way to use latest certificates from Key Vault

#1
Announcing an easier way to use latest certificates from Key Vault

<div style="margin: 5px 5% 10px 5%;"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/02/announcing-an-easier-way-to-use-latest-certificates-from-key-vault.png" width="1024" height="723" title="" alt="" /></div><div><p><i>Posting on behalf of <a href="https://blogs.msdn.microsoft.com/webdev/2019/02/07/announcing-an-easier-way-to-use-latest-certificates-from-key-vault/#Prashanth">Prashanth Yerramilli</a></i></p>
<p>When we launched Azure Key Vault a few years ago, it solved a major problem users had which was that storing sensitive and/or secret information in code or config files in plain text causes multiple problems including security exposure. Users stored their secrets in a safe store like Key Vault and used a URI to fetch the secret material. This service has been wildly popular and has become a standard for cloud applications. It is used by fledling startups to Fortune 500 companies world over.</p>
<p>Developers use Key Vault to store their adhoc secrets, certificates and keys used for encryption. And to follow best security practices they create secrets that are short lived. An example of typical flow in this case could be</p>
<ul>
<li>Step 1: Developer creates a certificate in Key Vault</li>
<li>Step 2: Developer sets the lifetime of the secret to be 30 day. In other words developer asks Key Vault to re-create the certificate every 30 days. Developer also chooses to receive an email when a certificate is about to expire</li>
<li>Step 3: Developer writes a polling service to check if the certificate has indeed expired</li>
</ul>
<p>In the above scenario there are few challenges for the customer. They would have to write a polling service that constantly checks if the certificate has expired and if so they wait for the new certificate and then bind it in Windows Certificate manager.<br />Now what if developer doesn’t have to poll. And also if the developer doesn’t have to bind the new certificate in Windows Certificate manager. To solve this exact problem we built a Key Vault Virtual Machine Extension.</p>
<p>Azure virtual machine (VM) extensions are small applications that provide post-deployment configuration and automation tasks on Azure VMs. For example, if a virtual machine requires software installation, anti-virus protection, or to run a script inside of it, a VM extension can be used. Azure VM extensions can be run with the Azure CLI, PowerShell, Azure Resource Manager templates, and the Azure portal. Extensions can be bundled with a new VM deployment, or run against any existing system.<br />To learn more about VM Extensions please click <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/features-windows">here</a></p>
<p>Key Vault VM Extension is supposed to do just that as explained in the steps below</p>
<ul>
<li>Step 1: Create a Key Vault and create an Azure Windows Virtual Machine</li>
<li>Step 2: Install the Key Vault VM Extension on the VM</li>
<li>Step 3: Configure Key Vault VM Extension to monitor a specific vault by specifying how often it should fetch the certificate</li>
</ul>
<p>By doing the above steps the latest certificate is bound correctly in Windows Certificate Manager. This feature enables auto-rotation of SSL certificates, without necessitating a re-deployment or binding.</p>
<p>In the lifecycle of secrets management fetching the latest version of the secret (for the purpose of this article a certificate) is just as important as storing it securely. To solve this problem, on an Azure Virtual Machine, we’ve created a VM Extension for Windows. A Linux version is coming soon.<br />Virtual Machine Extensions are small applications that provide post-deployment configuration and automation tasks on Azure VMs. In this case the Key Vault Virtual Machine extension once installed fetches the latest version of the certificate at a specified interval and automatically binds the latest version of the certificate in the certificate store on Windows. As you can see this feature enables auto-rotation of SSL certificates, without necessitating a re-deployment or binding.</p>
<p>Also before we begin going through the tutorial, we need to understand a concept called <a href="https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview">Managed Identities</a>.<br />Your code needs credentials to authenticate to cloud services, but you want to limit the visibility of those credentials as much as possible. Ideally, they never appear on a developer’s workstation or get checked-in to source control. Azure Key Vault can store credentials securely so they aren’t in your code, but to retrieve them you need to authenticate to Azure Key Vault. To authenticate to Key Vault, you need a credential! A classic bootstrap problem. Through the magic of Azure and Azure AD, MI provides a “bootstrap identity” that makes it much simpler to get things started.</p>
<p>Here’s how it works: When you enable MI for an Azure resource such as a virtual machine, Azure creates a Service Principal (an identity) for that resource in Azure AD, and injects the credentials (of that identity) into the resource (in this case a virtual machine).</p>
<ol>
<li>Your code calls a local MI endpoint to get an access token</li>
<li>MI uses the locally injected credentials to get an access token from Azure AD</li>
<li>Your code uses this access token to authenticate to an Azure service</li>
</ol>
<p><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/02/announcing-an-easier-way-to-use-latest-certificates-from-key-vault.png" alt="Managed Identities" /></p>
<p>Now within Managed Identities there are 2 types</p>
<ol>
<li><strong>System Assigned managed identity</strong> is enabled directly on an Azure service instance. When the identity is enabled, Azure creates an identity for the instance in the Azure AD tenant that’s trusted by the subscription. The lifecycle of the identity is managed by Azure and is tied to the Azure service instance.</li>
<li><strong>User Assigned managed identity</strong> is created as a standalone Azure resource. Users first create an identity and then assign that identity to one or more Azure resources.</li>
</ol>
<p>In this tutorial I will demonstrate how to create a Azure Virtual Machine with an <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authoring-templates">ARM template</a> which also includes creating a Key Vault VM Extension on the VM.</p>
<h2 id="prerequisites">Prerequisites</h2>
<h2 id="step1">Step 1</h2>
<p>After the prerequisites are complete, create an System Assigned identity by following this <a href="https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/qs-configure-portal-windows-vm#system-assigned-managed-identity">tutorial</a></p>
<h2 id="step2">Step 2</h2>
<p>Assign the newly created System Assigned identity to access to your Key Vault</p>
<ul>
<li>Go to https://portal.azure.com and navigate to your Key Vault</li>
<li>Select Access Policies section and Add New by searching for the User Assigned identity<br /><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/02/announcing-an-easier-way-to-use-latest-certificates-from-key-vault-1.png" alt="AccessPolicies" /></li>
</ul>
<p><!--TODO: Why was this step needed?--></p>
<h2 id="step3">Step 3</h2>
<p>Create or Update a VM with the following ARM template<br />You can view full the ARM template <a href="https://msazure.visualstudio.com/One/_git/Azure-KeyVault-Docs?path=%2FKeyVaultDocs%2FKeyVault%2FKVVMARMTemplate.json">here</a> and the ARM Parameters file <a href="https://msazure.visualstudio.com/One/_git/Azure-KeyVault-Docs?path=%2FKeyVaultDocs%2FKeyVault%2FKVVMARMParameters.json">here</a>.</p>
<p>The most minimal settings in the ARM template are shown below:</p>
<pre><code> { "secretsManagementSettings": { "observedCertificates": [ "&lt;KeyVault URI of a secret to be monitored/retrieved, in versionless format: https://myVaultName.vault.azure.net/secrets/myCertName"&gt;, "&lt;more entries here&gt;", "pollingIntervalInS": "[parameters('kvvmextPollingInterval')]", ] } }
</code></pre>
<p>As you can see we only specify the observedCertificates parameter and polling Interval in seconds</p>
<p><!--TODO: Explain what this template is doing.--><br /><b>Note: Your observedCertificates urls should be of the form:</b></p>
<pre><code>https://myVaultName.vault.azure.net/secrets/myCertName

and not:

https://myVaultName.vault.azure.net/cert...myCertName

Reason being the /secrets path returns the full certificate, inluding the private key, while the /certificates path does not.
</code></pre>
<p>By following this <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-quickstart-create-templates-use-the-portal">tutorial</a> you can create a VM with the above specified template</p>
<p>The above tutorial assumes that you are storing your certificates on Windows Certificate Manager. And so the VM Extension pulls down the latest certificates at a specified interval and automatically binds those certificates in your certificate manager.</p>
<p>That’s all folks!</p>
<p><strong>Linux Version:</strong> We’re actively working on a VM Extension for Linux and would love to hear any feedback you might have.</p>
<p>We are eager to hear from you about your use cases and how we can evolve the VM Extension to help you. So please reach out to us and add your feature requests to <a href="https://feedback.azure.com/forums/906355-azure-key-vault">the Azure feedback forum</a>. If you run into issues using the VM extension please reach out to us on <a href="https://stackoverflow.com/questions/tagged/azure-keyvault">StackOverflow</a>.</p>
<p><strong>Prashanth Yerramilli, Senior Program Manager, Azure Key Vault</strong></p>
<p><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/02/announcing-an-easier-way-to-use-latest-certificates-from-key-vault.jpg" alt="Prashanth Yerramilli Profile Pic" width="200" height="200" /> Prashanth Yerramilli is the Key Vault Program Manager on the Azure Security team. He has over 10 years of Software Engineering experience and brings to the team love for creating the ultimate development experience.</p>
<p>Prashanth can be reached at:<br />-Twitter <a href="https://twitter.com/yvprashanth1">@yvprashanth1</a><br />-GitHub <a href="https://github.com/yvprashanth">https://github.com/yvprashanth</a></p>
<p> </p>
</div>
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016