Difference between revisions of "Letsencrypt"

From SME Server
Jump to navigationJump to search
m (Add correct wiki page for Note re fail on All)
 
(192 intermediate revisions by 16 users not shown)
Line 1: Line 1:
{{WIP box}}
+
{{Languages|Letsencrypt}}
{{Level|Advanced}}
+
{{Level|Medium}}
{{Warning box|This procedure  change the default certificates and could significantly compromise your server's security.<br />Thorough understanding of linux system management is required.<br /><br /><b>Proceed at your own risk</b>}}
+
<!-- here we define the contrib name variable -->
==Introduction==
+
<!-- we get the page title, remove suffix for translated version; if needed you can define there with the value you want-->
Let’s Encrypt is a new Certificate Authority:  
+
{{#vardefine:contribname| {{lc: {{#titleparts:  {{BASEPAGENAME}} |1}} }} }}
It’s free, automated, and open.
+
{{#vardefine:smecontribname| smeserver-{{lc: {{#titleparts:  {{BASEPAGENAME}} |1}} }} }}
It's main purpose is to allow people to encrypt the internet traffic by a very simple system.
+
<!-- we define the language -->
 +
{{#vardefine:lang| {{lc:  {{#titleparts:    {{PAGENAME}} | | -1}}  }} |en }}
 +
{{Infobox contribs
 +
|name={{#var:contribname}}
 +
|image={{#var:contribname}}.jpg
 +
|description_image= {{#var:contribname}} logo
 +
|maintainer= John Crisp
 +
|licence= MIT license
 +
|url= https://github.com/dehydrated-io/dehydrated
 +
|category= certificates
 +
|tags=dehydrated,letsencrypt,dns,http,ssl
 +
}}
 +
==Maintainer==
 +
John Crisp
  
The certs delivered must be renewed every 3 months.
+
== Version ==
 +
{{#set: Version=Contrib10}}
 +
{{#smeversion:smeserver-letsencrypt }}
 +
<br>
 +
 
 +
==Description==
 +
 
 +
{{warning box| The original protocol used by Let’s Encrypt for certificate issuance and management is called ACMEv1. In March of 2018 Letsencrypt introduced support for ACMEv2, a newer version of the protocol that matches what was finalized today as RFC 8555 328. They have been encouraging subscribers to move to the ACMEv2 protocol.
 +
 
 +
In March 2019 they announced an end of life plan for ACMEv1.
 +
 
 +
In November of 2019 they will stop allowing new account registrations through their ACMEv1 API endpoint. '''IMPORTANTLY''' Existing accounts will continue to function normally.
 +
 
 +
In June of 2020 they will stop allowing new domains to validate via ACMEv1.
 +
 
 +
Starting at the beginning of 2021 they will occasionally disable ACMEv1 issuance and renewal for periods of 24 hours, no more than once per month (OCSP service will not be affected). The intention is to induce client errors that might encourage subscribers to update to clients or configurations that use ACMEv2.
 +
 
 +
Renewal failures should be limited since new domain validations will already be disabled and we recommend renewing certificates 30 days before they expire.
 +
 
 +
In June of 2021 they will entirely disable ACMEv1 as a viable way to get a Let’s Encrypt certificate.}}
 +
 
 +
[https://letsencrypt.org/ Let’s Encrypt] is a new Certificate Authority:
 +
It’s free, automated, and open.  Its main purpose is to allow people to encrypt their internet traffic at no cost, easily, and automatically.  The certs delivered must be renewed every 3 months.
 +
 
 +
As of December 2015, the Letsencrypt service is in a public beta state.  They issue valid, trusted certificates, but the client code (and, to a lesser extent, the server code) is likely in a state of flux.  At least during the initial stages of the public beta, they're implementing rate-limiting, allowing no more than five certificates per domain in a rolling seven-day period.  This may make them unsuitable for users of dynamic DNS services.  The latest information about rate limiting should be posted on [https://letsencrypt.org/docs/rate-limits/ this page] of the letsencrypt.org documentation.  As of March 26, 2016, the rate limit has been increased to 20 certificates per domain per week.
 +
 
 +
If you're going to be testing things in ways that would involve requesting lots of certificates in a short period of time, you're encouraged to use the Letsencrypt staging CA for this purpose.  Certificates generated by this CA will not be trusted by your browser, and will appear to be issued by the "Fake LE Intermediate X1", but it will allow you to validate the toolchain and workflow.
 +
 
 +
The current status of the Letsencrypt services can be found on their [https://letsencrypt.status.io/ status page].
 +
 
 +
Multiple clients are available for the Letsencrypt services.  The official "certbot" client from letsencrypt.org is quite full-featured, but has a number of dependencies that it needs to install.  It also requires a newer version of Python than is included with a standard SME Server installation.  Due to this complexity, and the lack of compatibility with SME 8.x, this document describes installation and use of ''[https://github.com/lukas2511/dehydrated dehydrated]'', an alternative client implemented as a BASH shell script.
  
 
==Prerequisites==
 
==Prerequisites==
Your SME Server must be setup correctly with a FQDN and correctly setup DNS with your ISP. Your SME Server must also be connected to the internet, for the below procedure will interact with Letsencrypt servers. Make sure you've got this all setup correctly before continuing.
+
The Letsencrypt client and server interact to confirm that the person requesting a certificate for a hostname actually controls that host.  For this reason, there are some prerequisites for your configuration.  For example, if you're trying to obtain a certificate for www.example.com, the following conditions must be met:
 +
 
 +
* www.example.com is a valid domain name--the domain has been registered, and DNS records are published for it.
 +
* www.example.com resolves to your SME Server--published DNS records give the external IP address of your SME Server when queried for www.example.com.
 +
* Your SME Server is connected to the Internet, and is able to make outbound connections on ports 80 and 443.
 +
* Port 80 on your SME Server is open to the Internet (i.e., the Internet can reach your server on port 80)--you aren't behind a firewall, or some ISP filtering, that would block it.  If you've made SSL mandatory for the Primary ibay, port 443 must also be open.
 +
 
 +
Letsencrypt will issue certificates that include multiple hostnames (for example, www.example.com, example.com, and mail.example.com), all of which would be part of the request.  All of the conditions above must be true for all of the hostnames you want to include in the certificate.
 +
 
 +
Make sure you've got this all set up correctly before continuing.
  
== Installation ==
+
==Preparation==
For the installation of Letsencrypt, the initial generation of the certificates and periodically re-new the authority certificates, at minimum Python version 2.7 is required. By default SME Server comes with a lower version, but below instruction will enable you to install version 2.7 in a 'supported' way, next to the default SME Server Python version. The newly installed Python version 2.7 will then only be used (after initial installation) for the renewal of the certificates (periodically and mandatory every 3 months).
+
 
   
+
Before you begin installation, check to see if you or an installed contrib have configured any custom values for your TLS/SSL certificate:
Follow the instructions at [[Software_Collections]] and the python related wiki page specifically. You need to add the scl-repository for Python 2.7 that can be found [http://wiki.contribs.org/Scl#tab=Python27 '''here''']
+
# config show modSSL
 +
By default it would show:
 +
modSSL=service
 +
    TCPPort=443
 +
    access=public
 +
    status=enabled
 +
 
 +
If this shows any values for crt, key, or CertificateChainFile, make a note of them.  If you encounter an issue with the certificate files generated by Letsencrypt, you'll then be able to revert your changes. To make a 'backup' of your existing key and properties you can issue:
 +
config show modSSL > "/root/db_configuration_modSSL_backup_$(date +%Y%m%d_%H%M%S)"
 +
 
 +
==Installation of Dehydrated letsencrypt contrib==
 +
John Crisp has prepared a contrib that installs the dehydrated script, creates the appropriate configuration files, and integrates with the SME templates system. This is the simplest way to install dehydrated on your SME Server.
 +
<tabs container style="display: inline-block;"><tab name="For SME 10">
 +
yum install smeserver-letsencrypt
 +
 
 +
You will then need to configure the domains and hosts for which you want to ask a certificate. See the following Configuration section.
 +
 
 +
If your smeaddons repo has been disabled add --enablerepo=smeaddons and reenable it, as it should be by default.
 +
db yum_repositories setprop smeaddons status enabled
 +
signal-event yum-modify
 +
 
 +
</tab><tab name="For SME 9">
 +
===Installation===
 +
yum install smeserver-letsencrypt
 +
signal-event console-save
 +
 
 +
You will then need to configure the domains and hosts for which you want to ask a certificate. See the following Configuration section.
 +
 
 +
If your smeaddons repo has been disabled add --enablerepo=smeaddons and reenable it, as it should be by default.
 +
db yum_repositories setprop smeaddons status enabled
 +
signal-event yum-modify
 +
 
 +
===Updating===
 +
Few reported issue when upgrading the contribs  see [[Bugzilla:10286]] and [[Bugzilla:10097]]
 +
 
 +
A full update can be done as follow :
 +
yum update smeserver-letsencrypt dehydrated
 +
config setprop letsencrypt ACCEPT_TERMS yes
 +
signal-event console-save
 +
failure to do this might leave the contribution not working and your certificates not renewed.
 +
</tab>
 +
</tabs>
 +
 
 +
==Configuration==
 +
There are several configuration database entries that need to be made in order to set up this contrib.  Most of them tell the scripts which hostnames need to be part of your certificate.
 +
 
 +
=== Rush jobs ===
 +
For the test ('''adjust the domains and hosts'''):
 +
<tabs container style="display: inline-block;"><tab name="For SME 10">
 +
config setprop letsencrypt ACCEPT_TERMS yes status test
 +
# really fast job to enable the primary domain
 +
db domains setprop $(config get DomainName) letsencryptSSLcert enabled
 +
#foreach of your domains you want SSL do the following
 +
db domains setprop '''domain1.com''' letsencryptSSLcert enabled
 +
#foreach of your hosts (subdomains) you want SSL do the following
 +
db hosts setprop '''www.domain1.com''' letsencryptSSLcert enabled
 +
signal-event smeserver-letsencrypt-update
 +
dehydrated -c
 +
</tab><tab name="For SME 9">
 +
config setprop letsencrypt ACCEPT_TERMS yes status test API 2
 +
#foreach of your domains you want SSL do the following
 +
db domains setprop '''domain1.com''' letsencryptSSLcert enabled
 +
#foreach of your hosts (subdomains) you want SSL do the following
 +
db hosts setprop '''www.domain1.com''' letsencryptSSLcert enabled
 +
signal-event console-save
 +
dehydrated -c
 +
</tab>
 +
</tabs>
 +
Check that the certificates are available ( your browser will still issue an error, but you can explore the content of the certificate to see that the Let's Encrypt test CA was used to sign your SSL certificate and that all your domains and hosts are in the "Certificate Subject Alt Name" property.
 +
 
 +
For the production ('''adjust your email'''):
 +
<tabs container style="display: inline-block;"><tab name="For SME 10">
 +
config setprop letsencrypt status enabled email admin@$(config get DomainName)
 +
signal-event smeserver-letsencrypt-update
 +
dehydrated -c -x
 +
</tab><tab name="For SME 9">
 +
config setprop letsencrypt status enabled email '''admin@domain1.com'''
 +
signal-event console-save
 +
  dehydrated -c -x
 +
</tab>
 +
</tabs>
 +
 
 +
===Step by step configuration===
 +
 
 +
====Hosts and domains for the certificate====
 +
This contrib will obtain a single certificate from Let's Encrypt.  The certificate will include all the domains and hostnames that:
 +
* Are configured on your SME Server (e.g., through the Server Manager), and
 +
* Are configured to use Let's Encrypt.
 +
 
 +
For example, your SME Server may contain the following domains and hostnames:
 +
 
 +
* domain1.com
 +
** www.domain1.com
 +
** mail.domain1.com
 +
** ftp.domain1.com
 +
 
 +
* domain2.com
 +
** www.domain2.com
 +
** mail.domain2.com
 +
For each DOMAIN that you want to be included in the certificate, run this command:
 +
db domains setprop $DOMAIN letsencryptSSLcert enabled
 +
 
 +
Using the above example, one invocation of the command would look like this:
 +
db domains setprop domain1.com  letsencryptSSLcert enabled
 +
 
 +
For each HOSTNAME that you want to be included in the certificate, run this command:
 +
db hosts setprop $HOSTNAME letsencryptSSLcert enabled
 +
 
 +
Using the above example, one invocation of the command would look like this:
 +
db hosts setprop www.domain1.com letsencryptSSLcert enabled
 +
 
 +
You can obtain a certificate for either of the following: all domains, all hostnames, or all domains AND hostnames. Only set one of the following.
 +
 
 +
config setprop letsencrypt configure domains
 +
 
 +
config setprop letsencrypt configure hosts
 +
 
 +
config setprop letsencrypt configure all
 +
 
 +
To use individually enabled hosts or domains leave the default none.
 +
 
 +
config setprop letsencrypt configure none
 +
 
 +
 
 +
With the system configuration described above, setting this to "domains" will obtain a certificate covering domain1.com and domain2.com, but not www.domain1.com, etc.  Setting it to "hosts" will obtain a certificate covering www.domain1.com, mail.domain1.com, ftp.domain1.com, etc., but not domain1.com or domain2.com. Setting this property to "all" will include all domain names and hostnames in the certificate. '''See [[Letsencrypt/Troubleshooting#Some_challenges_complete_successfully_but_some_hostnames_fail|NOTE]] before setting this to "all".'''
 +
 
 +
==== Enable test mode ====
 +
After installing and configuring all the domains and hosts, the next step is to use test mode, which is enabled by default.  This will obtain certificates from the staging server.  The rate limits discussed in the introduction won't apply, so any errors or other issues won't prevent you from obtaining your production certificate.  Enable test mode using this command:
 +
config setprop letsencrypt status test
 +
signal-event console-save
 +
 
 +
You can now run dehydrated for the first time, and make sure it's able to connect to the Let's Encrypt servers, validate the hostnames you're requesting, and issue certificates.  To do this, run
 +
dehydrated -c
 +
 
 +
If it prints only "# INFO: Using main config file /etc/dehydrated/config" and returns you to the shell prompt, see [[Bugzilla:10300]].
 +
 
 +
{{Note box|Solution for error "Malformed account ID in KeyID header URL" using API 2, for contrib versions 0.6.13 or older See [[Bugzilla:10828]] or update to latest contrib}}
  
Then:
+
If this runs without errors, try to connect to your server-manager page. You should see an error that the security certificate wasn't issued by a trusted certification authority; this is perfectly normal.  However, there should be a certificate, it should include all the hostnames you wanted included, and it should be valid for the next ninety days. If this was successful, proceed to production.
  yum install python27 --enablerepo=scl-python27
 
  yum install git
 
  
{{Note box| We need to see if installing GIT is really required, for the GIT version is also available as a ZIP file. The less we install, the better.}}
+
====Enable Production Mode====
 +
Once you've successfully tested your installation, set it to production mode using these commands:
  
To use Let's Encrypt run:
+
config setprop letsencrypt status enabled
  scl enable python27 bash
+
  signal-event console-save
  cd /opt
+
   
git clone https://github.com/letsencrypt/letsencrypt.git
+
Then obtain a new certificate from the Let's Encrypt production server:
cd letsencrypt
+
  dehydrated -c -x
service httpd-e-smith stop
 
  ./letsencrypt-auto certonly --standalone --email me@mydomain.co.uk -d test.firstdomain.co.uk -d seconddomain.co.uk -d www.seconddomain.co.uk
 
  
Replacing email and domains as required. Then configure SME with the certificates generated:
+
The -x flag here is needed to force dehydrated to obtain a new certificate, even though you have an existing certificate that's valid for more than 30 days.
  
  config setprop modSSL crt /etc/letsencrypt/live/test.firstdomain.co.uk/cert.pem
+
If this command succeeded, congratulations! You've successfully obtained a valid, trusted TLS certificate, which will automatically renew itself in perpetuity.  
config setprop modSSL key /etc/letsencrypt/live/test.firstdomain.co.uk/privkey.pem
 
config setprop modSSL CertificateChainFile /etc/letsencrypt/live/test.firstdomain.co.uk/chain.pem
 
signal-event domain-modify; signal-event email-update
 
  
{{Note box|We need to see if setting the above db variables disturbs other SME Server default functionality and contribs that work with certificates such as VPN solutions.}}
+
Once you've obtained your certificate and configured your server, test your server with a tool like [https://www.ssllabs.com/ssltest/ SSLLabs.com] to make sure it's working properly.
  
== Renew of the certs ==
+
====Archive old certificates====
  
The following script will automatically renew your certificate. Save it in a convenient place, for example, /opt/letsencrypt-renew.sh;dont forget du chmod +x the file
+
A new function lets you cleanup old and archive old certificates.
  
  #!/bin/bash
+
  dehydrated --cleanup (-gc)
source /opt/rh/python27/enable
 
export X_SCLS="`scl enable python27 'echo $X_SCLS'`"
 
/sbin/service httpd-e-smith stop
 
/opt/letsencrypt/letsencrypt-auto certonly --standalone --renew-by-default --email me@mydomain.co.uk \
 
  -d test.firstdomain.co.uk -d seconddomain.co.uk -d www.seconddomain.co.uk
 
/sbin/e-smith/signal-event domain-modify
 
/sbin/e-smith/signal-event email-update
 
/sbin/e-smith/signal-event ibay-modify
 
  
You may want to set this up as a cron job to run every two months, to make sure your certificate doesn't expire. Please see '''[[Crontab_Manager]]''' contrib for an easy way to achieve thisOr, to set this from the command line, do the following:
+
===Configuration properties===
 +
{| class="wikitable"
 +
!Key
 +
!property
 +
!default
 +
!values
 +
!
 +
|-
 +
| rowspan="10" |letsencrypt
 +
|ACCEPT_TERMS
 +
|
 +
|empty, yes
 +
|set to yes to accept terms of service, if left empty the contrib will not work.
 +
|-
 +
|API
 +
|2
 +
|1,2
 +
|deprecated, will always be v2, as v1 is deprecated as per june 2021
 +
|-
 +
|configure
 +
|none
 +
|none,all,domains,hosts
 +
|this will change the default behaviour on non explicitly domains or hosts with "letsencryptSSLcert enabled". By default will not be used, if hosts is set will ask a cert for all hosts, if domains is set will ask a cert for all domains, if all is set, will ask for both domains and hosts. In all situation it will ask a cert for domains/hosts where "letsencryptSSLcert enabled" is set and it is not set to "letsencryptSSLcert disabled"
 +
|-
 +
|email
 +
|
 +
|email
 +
|enter the email to create account and receive updates from Let's Encrypt
 +
|-
 +
|hookScript
 +
|disabled
 +
|enabled,disabled
 +
|will trigger advanced hook script if enabled, even if disabled the part to signal-event ssl-update to propagate the cert will run.
 +
|-
 +
|hostOverride
 +
|disabled
 +
|yes,disabled
 +
|default disabled, if disabled will only ask cert for hosts (if selected according to configure and "letsencryptSSLcert enabled") for hosts with type=Self. If set to yes will include any listed hosts whether remote or local.
 +
|-
 +
|keysize
 +
|4096
 +
|base 2 number
 +
|length of your certificate's private key, if you don't want the '''default of 4096''' bitsThis should not be necessary in most cases, but if desired, use this command to do so:
 +
|-
 +
|status
 +
|test
 +
|enabled,disabled,test
 +
|default status is disabled, '''First set it to test''' to connect to the test server of let's Encrypt to check if your server is well configured. After checking everything is ok, you can set it to enabled.
 +
|}
  
mkdir -p /etc/e-smith/templates-custom/etc/crontab
+
== Troubleshooting ==
nano /etc/e-smith/templates-custom/etc/crontab/sslrenew
+
see [[Letsencrypt/Troubleshooting]]
  
The following example will run the renewal script at 22:48 on the third of every other month (Feb, Apr, Jun, etc.):
+
== Advanced Topics ==
 +
see [[Letsencrypt/Advanced]]
  
48 22 3 */2 * root /opt/letsencrypt-renew.sh
 
  
then expand and restart
+
== Uninstall ==
 +
yum remove {{#var:smecontribname}}  {{#var:contribname}}
 +
== Bugs ==
 +
Please raise bugs under the SME-Contribs section in [http://bugs.contribs.org/enter_bug.cgi bugzilla]
 +
and select the smeserver-letsencrypt component or use {{BugzillaFileBug|product=SME%20Contribs|component=smeserver-letsencrypt|title=this link}}
  
expand-template /etc/crontab
+
{{#bugzilla:columns=id,product,version,status,summary |sort=id |order=desc |component=smeserver-letsencrypt |disablecache=1|noresultsmessage="No open bugs found."}}
service crond restart
 
  
The time and day of the month can be chosen at your discretion--I've deliberately chosen a time that isn't at the top or bottom of the hour, or on the first of the month, in the hope of reducing load on letsencrypt's servers.  Since the certificates are good for 90 days, this will renew your certificate in plenty of time.
+
== Changelog ==
 +
Only released version in smecontrib are listed here.
  
== Backup ==
+
{{#smechangelog:smeserver-letsencrypt}}
Your certificate, private key, and other important information are stored in /etc/letsencrypt, which is not included in the standard SME Server backup routines.  Make sure to add this directory to your backups.  See, e.g., [[Backup with dar#Adding files and directories|Backup with dar]] if you're using the workstation backup feature.
 
  
==Source from info==
+
[[Category:Contrib]]
Source: http://forums.contribs.org/index.php/topic,51961.msg266680.html#msg266680
+
[[Category:Howto]]  
[[Category:Howto]] [[Category:Security]] [[Category:Howto]]
+
[[Category:Security]]
 +
[[Category: Administration:Certificates]]

Latest revision as of 08:18, 15 December 2023


PythonIcon.png Skill level: Medium
The instructions on this page require a basic knowledge of linux.




letsencrypt
NeedImage.svg
letsencrypt logo
MaintainerJohn Crisp
Urlhttps://github.com/dehydrated-io/dehydrated
LicenceMIT license
Category

certificates

Tags dehydratedletsencryptdnshttpssl


Maintainer

John Crisp

Version

Add-on 10:
Contrib 9:
smeserver-letsencrypt
The latest version of smeserver-letsencrypt is available in the SME repository, click on the version number(s) for more information.



Description

Warning.png Warning:
The original protocol used by Let’s Encrypt for certificate issuance and management is called ACMEv1. In March of 2018 Letsencrypt introduced support for ACMEv2, a newer version of the protocol that matches what was finalized today as RFC 8555 328. They have been encouraging subscribers to move to the ACMEv2 protocol.

In March 2019 they announced an end of life plan for ACMEv1.

In November of 2019 they will stop allowing new account registrations through their ACMEv1 API endpoint. IMPORTANTLY Existing accounts will continue to function normally.

In June of 2020 they will stop allowing new domains to validate via ACMEv1.

Starting at the beginning of 2021 they will occasionally disable ACMEv1 issuance and renewal for periods of 24 hours, no more than once per month (OCSP service will not be affected). The intention is to induce client errors that might encourage subscribers to update to clients or configurations that use ACMEv2.

Renewal failures should be limited since new domain validations will already be disabled and we recommend renewing certificates 30 days before they expire.

In June of 2021 they will entirely disable ACMEv1 as a viable way to get a Let’s Encrypt certificate.


Let’s Encrypt is a new Certificate Authority: It’s free, automated, and open. Its main purpose is to allow people to encrypt their internet traffic at no cost, easily, and automatically. The certs delivered must be renewed every 3 months.

As of December 2015, the Letsencrypt service is in a public beta state. They issue valid, trusted certificates, but the client code (and, to a lesser extent, the server code) is likely in a state of flux. At least during the initial stages of the public beta, they're implementing rate-limiting, allowing no more than five certificates per domain in a rolling seven-day period. This may make them unsuitable for users of dynamic DNS services. The latest information about rate limiting should be posted on this page of the letsencrypt.org documentation. As of March 26, 2016, the rate limit has been increased to 20 certificates per domain per week.

If you're going to be testing things in ways that would involve requesting lots of certificates in a short period of time, you're encouraged to use the Letsencrypt staging CA for this purpose. Certificates generated by this CA will not be trusted by your browser, and will appear to be issued by the "Fake LE Intermediate X1", but it will allow you to validate the toolchain and workflow.

The current status of the Letsencrypt services can be found on their status page.

Multiple clients are available for the Letsencrypt services. The official "certbot" client from letsencrypt.org is quite full-featured, but has a number of dependencies that it needs to install. It also requires a newer version of Python than is included with a standard SME Server installation. Due to this complexity, and the lack of compatibility with SME 8.x, this document describes installation and use of dehydrated, an alternative client implemented as a BASH shell script.

Prerequisites

The Letsencrypt client and server interact to confirm that the person requesting a certificate for a hostname actually controls that host. For this reason, there are some prerequisites for your configuration. For example, if you're trying to obtain a certificate for www.example.com, the following conditions must be met:

  • www.example.com is a valid domain name--the domain has been registered, and DNS records are published for it.
  • www.example.com resolves to your SME Server--published DNS records give the external IP address of your SME Server when queried for www.example.com.
  • Your SME Server is connected to the Internet, and is able to make outbound connections on ports 80 and 443.
  • Port 80 on your SME Server is open to the Internet (i.e., the Internet can reach your server on port 80)--you aren't behind a firewall, or some ISP filtering, that would block it. If you've made SSL mandatory for the Primary ibay, port 443 must also be open.

Letsencrypt will issue certificates that include multiple hostnames (for example, www.example.com, example.com, and mail.example.com), all of which would be part of the request. All of the conditions above must be true for all of the hostnames you want to include in the certificate.

Make sure you've got this all set up correctly before continuing.

Preparation

Before you begin installation, check to see if you or an installed contrib have configured any custom values for your TLS/SSL certificate:

# config show modSSL

By default it would show:

modSSL=service
   TCPPort=443
   access=public
   status=enabled

If this shows any values for crt, key, or CertificateChainFile, make a note of them. If you encounter an issue with the certificate files generated by Letsencrypt, you'll then be able to revert your changes. To make a 'backup' of your existing key and properties you can issue:

config show modSSL > "/root/db_configuration_modSSL_backup_$(date +%Y%m%d_%H%M%S)"

Installation of Dehydrated letsencrypt contrib

John Crisp has prepared a contrib that installs the dehydrated script, creates the appropriate configuration files, and integrates with the SME templates system. This is the simplest way to install dehydrated on your SME Server.

yum install smeserver-letsencrypt

You will then need to configure the domains and hosts for which you want to ask a certificate. See the following Configuration section.

If your smeaddons repo has been disabled add --enablerepo=smeaddons and reenable it, as it should be by default.

db yum_repositories setprop smeaddons status enabled
signal-event yum-modify

Installation

yum install smeserver-letsencrypt
signal-event console-save

You will then need to configure the domains and hosts for which you want to ask a certificate. See the following Configuration section.

If your smeaddons repo has been disabled add --enablerepo=smeaddons and reenable it, as it should be by default.

db yum_repositories setprop smeaddons status enabled
signal-event yum-modify

Updating

Few reported issue when upgrading the contribs see Bugzilla:10286 and Bugzilla:10097

A full update can be done as follow :

yum update smeserver-letsencrypt dehydrated
config setprop letsencrypt ACCEPT_TERMS yes
signal-event console-save

failure to do this might leave the contribution not working and your certificates not renewed.

Configuration

There are several configuration database entries that need to be made in order to set up this contrib. Most of them tell the scripts which hostnames need to be part of your certificate.

Rush jobs

For the test (adjust the domains and hosts):

config setprop letsencrypt ACCEPT_TERMS yes status test
# really fast job to enable the primary domain
db domains setprop $(config get DomainName) letsencryptSSLcert enabled
#foreach of your domains you want SSL do the following
db domains setprop domain1.com letsencryptSSLcert enabled
#foreach of your hosts (subdomains) you want SSL do the following
db hosts setprop www.domain1.com letsencryptSSLcert enabled
signal-event smeserver-letsencrypt-update
dehydrated -c
config setprop letsencrypt ACCEPT_TERMS yes status test API 2
#foreach of your domains you want SSL do the following
db domains setprop domain1.com letsencryptSSLcert enabled
#foreach of your hosts (subdomains) you want SSL do the following
db hosts setprop www.domain1.com letsencryptSSLcert enabled
signal-event console-save
dehydrated -c

Check that the certificates are available ( your browser will still issue an error, but you can explore the content of the certificate to see that the Let's Encrypt test CA was used to sign your SSL certificate and that all your domains and hosts are in the "Certificate Subject Alt Name" property.

For the production (adjust your email):

config setprop letsencrypt status enabled email admin@$(config get DomainName)
signal-event smeserver-letsencrypt-update
dehydrated -c -x
config setprop letsencrypt status enabled email admin@domain1.com
signal-event console-save
dehydrated -c -x

Step by step configuration

Hosts and domains for the certificate

This contrib will obtain a single certificate from Let's Encrypt. The certificate will include all the domains and hostnames that:

  • Are configured on your SME Server (e.g., through the Server Manager), and
  • Are configured to use Let's Encrypt.

For example, your SME Server may contain the following domains and hostnames:

  • domain1.com
    • www.domain1.com
    • mail.domain1.com
    • ftp.domain1.com
  • domain2.com
    • www.domain2.com
    • mail.domain2.com

For each DOMAIN that you want to be included in the certificate, run this command:

db domains setprop $DOMAIN letsencryptSSLcert enabled

Using the above example, one invocation of the command would look like this:

db domains setprop domain1.com  letsencryptSSLcert enabled

For each HOSTNAME that you want to be included in the certificate, run this command:

db hosts setprop $HOSTNAME letsencryptSSLcert enabled

Using the above example, one invocation of the command would look like this:

db hosts setprop www.domain1.com letsencryptSSLcert enabled

You can obtain a certificate for either of the following: all domains, all hostnames, or all domains AND hostnames. Only set one of the following.

config setprop letsencrypt configure domains
config setprop letsencrypt configure hosts
config setprop letsencrypt configure all

To use individually enabled hosts or domains leave the default none.

config setprop letsencrypt configure none


With the system configuration described above, setting this to "domains" will obtain a certificate covering domain1.com and domain2.com, but not www.domain1.com, etc. Setting it to "hosts" will obtain a certificate covering www.domain1.com, mail.domain1.com, ftp.domain1.com, etc., but not domain1.com or domain2.com. Setting this property to "all" will include all domain names and hostnames in the certificate. See NOTE before setting this to "all".

Enable test mode

After installing and configuring all the domains and hosts, the next step is to use test mode, which is enabled by default. This will obtain certificates from the staging server. The rate limits discussed in the introduction won't apply, so any errors or other issues won't prevent you from obtaining your production certificate. Enable test mode using this command:

config setprop letsencrypt status test
signal-event console-save

You can now run dehydrated for the first time, and make sure it's able to connect to the Let's Encrypt servers, validate the hostnames you're requesting, and issue certificates. To do this, run

dehydrated -c

If it prints only "# INFO: Using main config file /etc/dehydrated/config" and returns you to the shell prompt, see Bugzilla:10300.


Important.png Note:
Solution for error "Malformed account ID in KeyID header URL" using API 2, for contrib versions 0.6.13 or older See Bugzilla:10828 or update to latest contrib


If this runs without errors, try to connect to your server-manager page. You should see an error that the security certificate wasn't issued by a trusted certification authority; this is perfectly normal. However, there should be a certificate, it should include all the hostnames you wanted included, and it should be valid for the next ninety days. If this was successful, proceed to production.

Enable Production Mode

Once you've successfully tested your installation, set it to production mode using these commands:

config setprop letsencrypt status enabled
signal-event console-save

Then obtain a new certificate from the Let's Encrypt production server:

dehydrated -c -x

The -x flag here is needed to force dehydrated to obtain a new certificate, even though you have an existing certificate that's valid for more than 30 days.

If this command succeeded, congratulations! You've successfully obtained a valid, trusted TLS certificate, which will automatically renew itself in perpetuity.

Once you've obtained your certificate and configured your server, test your server with a tool like SSLLabs.com to make sure it's working properly.

Archive old certificates

A new function lets you cleanup old and archive old certificates.

dehydrated --cleanup (-gc)

Configuration properties

Key property default values
letsencrypt ACCEPT_TERMS empty, yes set to yes to accept terms of service, if left empty the contrib will not work.
API 2 1,2 deprecated, will always be v2, as v1 is deprecated as per june 2021
configure none none,all,domains,hosts this will change the default behaviour on non explicitly domains or hosts with "letsencryptSSLcert enabled". By default will not be used, if hosts is set will ask a cert for all hosts, if domains is set will ask a cert for all domains, if all is set, will ask for both domains and hosts. In all situation it will ask a cert for domains/hosts where "letsencryptSSLcert enabled" is set and it is not set to "letsencryptSSLcert disabled"
email email enter the email to create account and receive updates from Let's Encrypt
hookScript disabled enabled,disabled will trigger advanced hook script if enabled, even if disabled the part to signal-event ssl-update to propagate the cert will run.
hostOverride disabled yes,disabled default disabled, if disabled will only ask cert for hosts (if selected according to configure and "letsencryptSSLcert enabled") for hosts with type=Self. If set to yes will include any listed hosts whether remote or local.
keysize 4096 base 2 number length of your certificate's private key, if you don't want the default of 4096 bits. This should not be necessary in most cases, but if desired, use this command to do so:
status test enabled,disabled,test default status is disabled, First set it to test to connect to the test server of let's Encrypt to check if your server is well configured. After checking everything is ok, you can set it to enabled.

Troubleshooting

see Letsencrypt/Troubleshooting

Advanced Topics

see Letsencrypt/Advanced


Uninstall

yum remove smeserver-letsencrypt  letsencrypt

Bugs

Please raise bugs under the SME-Contribs section in bugzilla and select the smeserver-letsencrypt component or use this link


IDProductVersionStatusSummary (10 tasks)
12325SME Contribs10.0CONFIRMEDrenewal fails after domain deleted from manager.
11796SME ContribsFuturCONFIRMEDIs the dns-01 Challenge Supported or is it in planing?
11442SME Contribs10alphaCONFIRMEDmultiple fragments related to some other bugs
10920SME Contribs10alphaCONFIRMEDmove .well-known/acme-challenge out of the Primary ibay
10836SME Contribs9.2CONFIRMEDforce migration from acme-v1 to acme-v2
10818SME Contribs9.2CONFIRMEDtemplate does not respect domain-deleted
10656SME Contribs9.2CONFIRMEDNo letsencrypt certificate for Internet enable password protected Ibay
10483SME Contribs9.2CONFIRMEDrenewal fails with ibay using password
10462SME ContribsFuturCONFIRMEDNFR: implement per certificate / domain
10280SME Contribs9.2CONFIRMEDadd test for domain and host to disable the one at least defined in publicly available dns

Changelog

Only released version in smecontrib are listed here.

smeserver-letsencrypt Changelog: SME 10 (smeaddons)
2022/07/30 Brian Read 0.5-24.sme
- Re-build and link to latest devtools [SME: 11997]
2022/07/25 Jean-Philippe Pialasse 0.5-23.sme
- add to core backup [SME: 12011]
2022/06/15 Brian Read 0.5-22.sme
- Add action to check if dehydrated.timer is running and stop it if so [SME: 11996]
2022/06/12 Brian Read 0.5-21.sme
- Stop systemd timer runnning as well as cron [SME: 11990]
2022/03/23 Jean-Philippe Pialasse 0.5-19.sme
- use a general Alias for acme path and a proxypass [SME: 10637]