<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tamas</title>
    <description>The latest articles on DEV Community by Tamas (@furotmark).</description>
    <link>https://dev.to/furotmark</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F527437%2F9febbf21-f45c-4309-b4c2-83e489425191.png</url>
      <title>DEV Community: Tamas</title>
      <link>https://dev.to/furotmark</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/furotmark"/>
    <language>en</language>
    <item>
      <title>Add Https to Azure Web App with Let's Encrypt</title>
      <dc:creator>Tamas</dc:creator>
      <pubDate>Mon, 04 Jan 2021 13:08:41 +0000</pubDate>
      <link>https://dev.to/furotmark/add-https-to-azure-web-app-with-let-s-encrypt-1jki</link>
      <guid>https://dev.to/furotmark/add-https-to-azure-web-app-with-let-s-encrypt-1jki</guid>
      <description>&lt;p&gt;You have deployed a web app docker container to Azure Web App service. Now you want to enable Https for the web application. &lt;br&gt;
This article will show you, how you can manage that from a Windows operating system. &lt;br&gt;
The creation and addition in this case will be manual. &lt;br&gt;
The certificate will be created with the help of Let's Encrypt. &lt;br&gt;
To transform the certificate into the right format for Azure, OpenSSL will be used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;If you do not have a custom domain name, you should consider the Certificate service from Azure. This is a free service, it creates a Digicert certificate and it also renews it automatically. It comes with limitations though.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To create a Let's Encrypt certificate, first, you should download the Certbot program from their site. The windows version is still in beta, but it works nonetheless. You can get it from &lt;a href="https://dl.eff.org/certbot-beta-installer-win32.exe"&gt;here&lt;/a&gt; or check out their site for instructions on how to install it &lt;a href="https://certbot.eff.org/lets-encrypt/windows-other"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After installing the Cerbot you should be able to call certbot commands from cmd or powershell.&lt;/p&gt;
&lt;h3&gt;
  
  
  Issuing a certificate
&lt;/h3&gt;

&lt;p&gt;The following command needs to be executed to create a certificate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;certbot certonly &lt;span class="nt"&gt;-d&lt;/span&gt; testDomain.com &lt;span class="nt"&gt;-d&lt;/span&gt; www.testDomain.com &lt;span class="nt"&gt;--manual&lt;/span&gt; &lt;span class="nt"&gt;--preferred-challenges&lt;/span&gt; dns
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;certonly&lt;/strong&gt; - only creates a certificate, does not install it on the machine&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;-d&lt;/strong&gt; - domain name specifier, you can add multiple domains, subdomains for a certificate&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;--preferred-challenges dns&lt;/strong&gt; - defines how you prove that the domain is under your administration. In this case with a DNS challenge. A DNS challenge requires you to add a DNS TXT record on your domain.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you use the DNS Zones service from Azure, you should add a new Record like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vfp76Nrd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j7erfnqrvr4x94nc3vdt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vfp76Nrd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j7erfnqrvr4x94nc3vdt.png" alt="Dns Challenge"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the DNS challenge is successfully made, you should have a message, that is successfully created the certificate. For the default installation the path where the certificate was exported is &lt;em&gt;C:\Certbot\archive&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The following files should be there:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cert.pem&lt;/li&gt;
&lt;li&gt;chain.pem&lt;/li&gt;
&lt;li&gt;fullchain.pem&lt;/li&gt;
&lt;li&gt;privkey.pem&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Converting the certificate for Azure
&lt;/h3&gt;

&lt;p&gt;Azure requires a private certificate in the PKCS#12 file format. Certbot does not generate it out of the box, but we can convert it to the right format with OpenSSL.&lt;/p&gt;

&lt;p&gt;For a pfx certificate this command needs to be run: with the files from the previous step.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openssl pkcs12 &lt;span class="nt"&gt;-export&lt;/span&gt; &lt;span class="nt"&gt;-out&lt;/span&gt; certificate.pfx &lt;span class="nt"&gt;-inkey&lt;/span&gt; privkey.pem &lt;span class="nt"&gt;-in&lt;/span&gt; cert.pem &lt;span class="nt"&gt;-certfile&lt;/span&gt; chain.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;You will have to give a password in this process, this password will be used later when we upload the certificate.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Uploading certificate to Azure Web App service
&lt;/h3&gt;

&lt;p&gt;Open App Service from the Azure Web portal. From the left navigation of your app, select &lt;strong&gt;TLS/SSL settings&lt;/strong&gt; &amp;gt; &lt;strong&gt;Private Key Certificates (.pfx)&lt;/strong&gt; &amp;gt; &lt;strong&gt;Upload Certificate&lt;/strong&gt;. Then add binding to the Custom Domain under the &lt;strong&gt;Custom Domain&lt;/strong&gt; section.&lt;/p&gt;

&lt;p&gt;More on this, in the official documentation:&lt;br&gt;
&lt;a href="https://docs.microsoft.com/en-us/azure/app-service/configure-ssl-certificate#upload-certificate-to-app-service"&gt;https://docs.microsoft.com/en-us/azure/app-service/configure-ssl-certificate#upload-certificate-to-app-service&lt;/a&gt;&lt;/p&gt;

</description>
      <category>azure</category>
      <category>https</category>
      <category>encrypt</category>
      <category>certificate</category>
    </item>
  </channel>
</rss>
