Tuesday, January 7, 2025

You can simplify the title by removing unnecessary words: Utilize WSL and Let’s Encrypt for Azure App Service SSL Wildcard Certificates

Can I utilize Certbot within WSL to generate wildcard certificates for my Azure Friday website, and subsequently integrate these certificates into my Azure App Service?

Azure App Service now requires a specific certificate format, specifically the .PFX file type, which includes both the root certificate and any intermediate certificates in the chain.

As per the documentation, App Service non-public certificates should meet the following requirements:

  • The exported certificate was saved in a password-protected PFX file, which utilized triple Data Encryption Standard (DES) for robust encryption.
  • Meets or exceeds the minimum requirement of a 2048-bit public key.
  • Ensures seamless integration of intermediate certificates and their underlying basis certificates within a comprehensive certificate chain.

If you encounter a PFX file that fails to comply with these prerequisites, Windows may automatically re-encrypt the file.

Using WSL and Certbot, I obtain a certificate; subsequently, I export it from Windows and import the resulting PFX file.

Inside WSL, set up certbot:

sudo apt replace
sudo apt-get install python3 python3-venv libaugeas0
sudo python3 -m venv /decide/certbot/
pip install --upgrade pip
sudo /decide/certbot/bin/pip set up certbot

Then I generate the cert. When using Certbot, you might encounter a friendly textual interface prompting you to update your DNS records as part of the verification process. Verify that all URLs within the text are accurate, ensuring correct tracing of domains, subdomains, and paths?

certbot certonly --manual --preferred-challenges dns --email your@email.com   
--server https://acme-v02.api.letsencrypt.org/listing
Here is the rewritten text: To agree to terms and conditions, configure public IP logging as acceptable, while targeting specific domains (`azurefriday.com` and its subdomains `*.azurefriday.com`) using the `-d` option.
The certificate export process for AzureFriday2023 is initiated using OpenSSL.
-inkey /and so on/letsencrypt/reside/azurefriday.com/privkey.pem
-in /and so on/letsencrypt/reside/azurefriday.com/fullchain.pem

I verify the desktop path and confirm that the copied file is now within the Windows environment.

sudo cp AzureFriday2023.pfx /mnt/c/Customers/Scott/OneDrive/Desktop

From within Windows, import the PFX file, carefully noting the displayed thumbprint, and subsequently export the certificate in its native format.

Import-PfxCertificate -FilePath "AzureFriday2023.pfx" -CertStoreLocation Cert:LocalMachineMy 
-Password (ConvertTo-SecureString -String 'password-should-be-complex-and-randomly-generated' -AsPlainText -ErrorAction Stop) -Force

Export-PfxCertificate -Cert Microsoft.PowerShell.SecurityCertificate::LocalMachineMy597THISISTHETHUMBNAILCF1157B8CEBB7CA1
FilePath 'AzureFriday2023-fixed.pfx' -Password (ConvertTo-SecureString -String 'PASSWORDHERE' -AsPlainText -Force)

Add the certificate to the Certificates section of your App Service under the Carry Your Personal Certificate entry.

Custom Domains in Azure App Service

Beneath the Customized Domains section, click on Replace Binding, then select the newly issued certificate with the latest expiration date.

image

To address the challenge effectively, we will proceed with a more computerized approach, which we can explore further in September, thereby resolving our expensive Wildcard Area issue.

About Scott

Scott Hanselman is a seasoned veteran of the tech industry, having transitioned from academia to roles such as Chief Architect in finance before devoting himself to speaking, advising, and raising a family as a proud father. Additionally, he has had to navigate life with diabetes, while also working for Microsoft. He’s a former stand-up comedian who didn’t quite make it, also a skilled hairstylist specializing in cornrows, and an author of digital books.

 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles