Guest User!

You are not Sophos Staff.

[LetsEncrypt] How To in Sophos Firewall

Disclaimer: This information is provided as-is for the benefit of the Community. Please contact Sophos Professional Services if you require assistance with your specific environment.

Hi Guys,

This Recommended Read goes over different options to obtain a Let's Encrypt certificate.

Overview

UTM has a LE Support for WAF (since UTM9.6). But on Sophos you can use LE certificates as well! Seems like many people does not know, you simply need a little Linux server and 5-10 minutes of your time each 3 month. Or you automate this. 

First of all, i want to share the "how it works" page of LE. https://letsencrypt.org/how-it-works/

My Setup. 

Internet - Sophos - Ubuntu 20.04 LTS
Ubuntu has "certbot" installed. Feel free to use other LE modules.
https://certbot.eff.org/ https://certbot.eff.org/lets-encrypt/ubuntubionic-apache
Follow straight the Guide for your OS. I am relying fully on those apps for the renewal process.  

Next step is, I am choosing the HTTP-01 method for LE, so i need a DNAT for LE to my Ubuntu.

 (V18). 

PS: I am using HTTP DNAT for the renewal process and deactivate those Rules after the process. But you can also use only the LE IPs: 
https://community.letsencrypt.org/t/can-i-get-list-ip-from-letsencrypt/57117
PS2: You could switch to the DNS validation like explained in this Community thread.  

Next steps would be to check your Domain. Your DNS A-Record should point to your WAN IP. Otherwise this process will not work. 
So perform a dig / nslookup of your domain. It should point to your WAN IP, so your DNAT will work and HTTP packets are forwarded to Certbot. 
You can also use the Sophos free DDNS service. https://community.sophos.com/kb/en-us/123126 

Certbot

Lets start certbot and try it. 
My renewal process is straight forward:


(Be careful: LE blocks you after couple of "failed" request for some time. So check everything!).
In the End you will get 4 files on your Linux: Public, Chain, Fullchain, Privatkey Certificates. 

Upload to Sophos Firewall

You will use this Public and Privatkey certificate. 
There are couple of approaches to upload this to Sophos . 

The first LE Cert can be simply uploaded. 
You should use the Public.pem in "Certificate" and the Privatkey in "Privat key". 
PS: you have to rename the Privatkey.pem to Privatkey.key, otherwise Sophos will not take this certificate. 

 

Optionally you can upload the other Chain and fullchain Certificate under Certificate Authorities (Without Privat key). 
Now you can use this Certificate for WAF/Webadmin. 

In case of renewal (each 90 Days), you have to choose a process.

Automation 


You can simply upload the new LE certificate with another Name and replace it in WAF/Webadmin. 
Or you can "update" the current LE certificate with new public.pem / privat.key. But for this method, you have to switch to a fallback certificate in WAF/Webadmin, because Sophos cannot update a certificate, which is currently in use.  

After all, those steps are manual process each 90 Days. 
You can "script" this, if you want to. So basically upload the certificate each 90 Days to Sophos . 
https://community.sophos.com/kb/en-us/132560
Other member in the community performed already scripts for this.
https://community.sophos.com/products/Sophos -firewall/f/sophos-Sophos -firewall-general-discussion/102208/upload-certificate-using-api
https://community.sophos.com/Sophos -firewall/f/discussions/126295/automatically-renew-let-s-encrypt-ssl-certificates-on-Sophos -using-powershell
https://github.com/mmccarn/sophos
https://community.sophos.com/sophos-Sophos -firewall/f/discussions/129768/letsencrypt-api-update-script---dynamically-handles-multiple-certs-multiple-rules-including-re-grouping-of-policies-rules
https://community.sophos.com/sophos-Sophos -firewall/f/discussions/134534/sophos-Sophos -api-lets-encrypt-powershell-7-waf-update
https://community.sophos.com/sophos-Sophos -firewall/f/discussions/138668/upload-certificates-using-powershell-to-automate-let-s-encrypt

If you want to script this, this community can help you in case you are struggling with a point! 
So simply open a new thread with your issue with the API, we will try to find a solution. 

Sophos Factory

Sophos Factory brings a new Tool to automate Script based approaches. This means, you can easily run a Script like Certbot or Lego in a Sophos Factory environment to generate the certificate and upload it to the Sophos Firewall. 

Sophos Factory offers a free Community Edition. https://community.sophos.com/sophos-factory/ https://community.sophos.com/sophos-factory/b/release-notes-news/posts/get-started-here-sophos-factory-offer-automation-for-all-with-its-free-community-edition

Within Sophos Factory it could look like this:

Each step is one scripting component. By Using tools like Lego and Github, the "Pipeline" will run one time, generate the certificate and upload it to the Firewall. 

Contribution:


 
 https://zerossl.com/free-ssl/#crt Free alternative to this approach
For the Github script. 
 Thanks for the PHP Script! 
 for a Powershell Script with WAF integration. 
 for another version of a Powershell Script. 



Updated Disclaimer
[edited by: Erick Jan at 9:16 AM (GMT -7) on 17 Apr 2023]
Parents
  • Great information, but it's really something that should be integrated into XG.

    Here's the link to the feature request. Over 400 votes and counting.

    Let's Encrypt Feature Request

  • I am aware of this, but i want to share a simple solution. 

    __________________________________________________________________________________________________________________

  • I appreciate your post here but not sure I’d say this is a simple or sensible solution for a couple of reasons.

    There’s probably two main ones but the first one is that you have to take your websites offline within 90 days to update the certificates. While your doing that the sites are going to display what? The default I’ve just installed Apache page unless you change it. Or are you mirroring all the WAF rules in Apache configuration to reverse proxy the sites while doing this or redirecting them to the real server? Do you add in mod security to try and keep the sites secure from attacks while you do this or do you publish them without?

    Which ever of these options your likely picking, this isn’t likely to fly at a lot of businesses in my experience.

    The other issue is that this is either manual or needs your own integration written. That’s a lot of effort compared to Sophos UTM where it’s pretty much fire and forget, doesn’t involve taking your sites offline either.

    So obviously until there’s an official solution if you wish to use XG and Letsencrypt you don’t have much choice but this is a very poor bandaid to something that should get built in natively.

  • I am only hosting a Certbot light version with apache right now. At the moment, i do not have any interrupt in the renewal process (beside the WAF restart in XG because i am changing the WAF rule). 

    Lets Encrypt can use only HTTP to verify the certificate. And it does not need any content on the page. You can read more about this process on the lets encrypt page and/or Certbot. 

    Do not forget, UTM got this last year (UTM9.6). Before that, every "LE integration" was a simple workaround by the community. 

     

    What i am doing is: 

    Enabling a DNAT Rule from Lets Encrypt IPs Port 80 to my Ubuntu Server.

    Starting Certbot to renewal the Certificate.

    Uploading the new Certificate to XG.

    Disabling the DNAT.

    Replacing the new Certificate in the WAF (OWA etc.) Rule and replacing the Certificate in the Webadmin. 

     


    I am simply point out a little workaround for the community. Also i am aware, that this is not quite a rock solid solution for a business case. I never told anybody, this is a "official" solution.

    Simply point out, that there is a way to work with this in the current product, if you want to.

     

    __________________________________________________________________________________________________________________

  • You can generate LE certs completely online BTW, skipping the entire Ubuntu setup process...

     

    https://zerossl.com/free-ssl/#crt

     

    Just need to provide DNS auth, which you should have anyway if even looking at this option.

Reply Children
No Data