Difference between revisions of "Cool Solution - Let's Encrypt"

From Univention Wiki

Jump to: navigation, search
Line 5: Line 5:
 
<!--|description=-->
 
<!--|description=-->
 
}}
 
}}
 +
'''Note:''' This cool solution has been released as an app in the Univention App Center. See [https://wiki.univention.de/index.php?title=Cool_Solution_-_Let%27s_Encrypt#Migrating_to_the_Let.27s_Encrypt_App Migrating to the Let's Encrypt App]
 +
 
Follow these instructions to setup certificates issued by [https://letsencrypt.org/getting-started/ Let's Encrypt] Certificate Authority in your UCS servers. For example to enable HTTPS in you website. Or for [http://sdb.univention.de/content/15/230/en/using-your-own-ssl-certificates.html other services] offering SSL/TLS encrypted communication.
 
Follow these instructions to setup certificates issued by [https://letsencrypt.org/getting-started/ Let's Encrypt] Certificate Authority in your UCS servers. For example to enable HTTPS in you website. Or for [http://sdb.univention.de/content/15/230/en/using-your-own-ssl-certificates.html other services] offering SSL/TLS encrypted communication.
  
Line 103: Line 105:
  
 
This cool solution has been released as an app for the Univention App Center.
 
This cool solution has been released as an app for the Univention App Center.
To migrate to the Let's Encrypt app, simply uninstall the Cool Solution package and unset the UCR variables associated with it. Existing host or domain keys below <code>/etc/univention/letsencrypt/</code> won't be removed and will be used by the app later.
+
To migrate to the Let's Encrypt app, simply uninstall the Cool Solution package. Existing host or domain keys below <code>/etc/univention/letsencrypt/</code> won't be removed and will be used by the app later.
 
 
<pre>ucr unset letsencrypt/domains letsencrypt/services/apache2 letsencrypt/services/postfix letsencrypt/services/dovecot</pre>
 
  
 
<pre>univention-remove univention-letsencrypt</pre>
 
<pre>univention-remove univention-letsencrypt</pre>
  
After that, install the app from the App Center in the UMC on your server and configure it, as explained in the readme that's being displayed after installation.
+
Afterwards, install the app from the App Center in the UMC on your server and configure it, as explained in the readme that's being displayed after installation.

Revision as of 09:04, 14 February 2018

Produktlogo UCS Version 4.2

Note: Cool Solutions are articles documenting additional functionality based on Univention products. Packages provided by a Cool Solutions Repository are built by Univention, but will not be maintained. Not all of the shown steps in the article are covered by Univention Support. For questions about your support coverage contact your contact person at Univention before you want to implement one of the shown steps.

Also regard the legal notes at Terms of Service.

Note: This cool solution has been released as an app in the Univention App Center. See Migrating to the Let's Encrypt App

Follow these instructions to setup certificates issued by Let's Encrypt Certificate Authority in your UCS servers. For example to enable HTTPS in you website. Or for other services offering SSL/TLS encrypted communication.

This article explains how to install a small Let's Encrypt client from our cool solution repository to generate and renew your TLS certificates, and how to configure different services to use them. The client uses the "ACME" protocol to negotiate with Let's encrypt servers.

Requirements

  • A valid DNS A record pointing to the public IP Address of your UCS server. For example, if the goal is to issue a certificate for service1.example.com, that server should be resolvable from the Internet:

You need an A record pointing to a public IP Address:

host -t A service1.example.com    
 service1.example.com has address 1.2.3.4

Installation

Install the letsencrypt client:

univention-install univention-letsencrypt

After installing the package univention-letsencrypt the client is ready for configuration.

Configuration

The package brings new UCR variables which are read by the scripts in /usr/share/univention-letsencrypt/. By default, letsencrypt/domains is empty and letsencrypt/services/* are set to 'no'.

UCR Variable Description Example
letsencrypt/services/apache2 Whether the Apache2 webserver should be configured automatically or not, valid values are "Yes" or "No"
letsencrypt/services/postfix Whether the postfix service should be configured automatically or not, valid values are "Yes" or "No"
letsencrypt/services/dovecot Whether the dovecot service should be configured automatically or not, valid values are "Yes" or "No"
letsencrypt/domains A list of DNS names on which the server is reachable, separated by spaces service1.example.com service2.example.com

Obtaining the certificate

Set the letsencrypt/domains before running the setup script:

ucr set letsencrypt/domains="service1.example.com"

Run the setup script /usr/share/univention-letsencrypt/setup-letsencrypt to automatically register an account, create the needed files and start the certificate creation and validation for the domains saved in the UCR variable letsencrypt/domains. The script installs a cronjob that periodically checks if the certificates must be renewed. All actions from the script are written into a the log file /var/log/univention/letsencrypt.log.

/usr/share/univention-letsencrypt/setup-letsencrypt

The certificate is saved in the directory /etc/univention/letsencrypt.

At the end, setup-letsencrypt checks the three service UCR variables and, if one is found set to "Yes", runs the needed scripts from the setup.d and post-refresh.d directories to configure the Apache2 webserver, postfix, or dovecot. Additional services can be configured by placing appropriate configuration scripts into these directories.

When the list of domains in letsencrypt/domains changes and setup-letsencrypt is run again, a prompt asks for deleting the current csr-file and recreates it with the new UCR variable's content.

Certificate update

The lifetime of the certificates issued by Let's Encrypt is limited to 90 days. By default, a cron job of univention-letsencrypt will update the certificate on the first day of every month at 3:30am. Services (like postfix, dovecot, apache) that have been setup via univention-letsencrypt will be restarted automatically during this process. The cron interval can be adjusted via the UCR variable letsencrypt/cron. If unset, the value 30 3 1 * * is used.

Troubleshooting

See the certificate by opening an encrypted connection

openssl s_client -connect service1.example.com:443

See how long your certificate is valid

openssl s_client -connect service1.example.com:443 | openssl x509 -noout -dates

If setup-letsencrypt fails, you can try the following:

Reset Apache SSL settings via UCR

ucr unset apache2/ssl/certificate apache2/ssl/certificatechain apache2/ssl/key

Unset forced HTTPS

ucr unset apache2/force_https

Check your Apache configuration

apache2ctl configtest

Make sure your host is reachable from the internet on the hostname that is configured in the UCR variable letsencrypt/domains. The folder that is being queried by Let's Encrypt is located at /var/www/.well-known/acme-challenge/

Verification fails in AWS or NAT environments

In certain scenarios, which incorporate NAT, or cloud environments like AWS, the internal domain verification of the App might fail, despite the DNS being configured correctly and Let's Encrypt being able to issue a certificate for the server. In these cases, adding a manual DNS entry on the system running the Let's Encrypt App can help:

ucr set hosts/static/<EXTERNAL-IPADDRESS>=<LETS-ENCRYPT-HOSTNAME>

Migrating to the Let's Encrypt App

This cool solution has been released as an app for the Univention App Center. To migrate to the Let's Encrypt app, simply uninstall the Cool Solution package. Existing host or domain keys below /etc/univention/letsencrypt/ won't be removed and will be used by the app later.

univention-remove univention-letsencrypt

Afterwards, install the app from the App Center in the UMC on your server and configure it, as explained in the readme that's being displayed after installation.

Personal tools