# LetsEncrypt

The LetsEncrypt plugin gets the server a certificate for its name, free, from Let's Encrypt, and renews it before it ends. Browsers and programs then trust the server's HTTPS, FTPS and WebDAV without anybody buying or installing a certificate.

It speaks ACME, the protocol Let's Encrypt made, so it also works with other certificate authorities that offer ACME.

The plugin is set up in Preferences › [Plugins](Prefs-Plugins.md) › **LetsEncrypt**. It comes with the server.

![The LetsEncrypt plugin in Preferences](Plugin-LetsEncrypt/screen.png)

"Please note: Your DNS host name must be reachable from the outside world or the Let's Encrypt validation will fail." That holds for the two usual kinds of proof. A server the internet cannot reach uses a DNS kind: [Let's Encrypt by DNS](Plugin-LetsEncrypt-DNS.md).

## The short way

For one server with a name that points at it, and port 80 open from the internet:

1. **Domains**: the name, such as `files.example.com`.
2. **Challenge type**: **http-01**, and under **Related CrushMFT Server Port** the HTTP port that the internet reaches as port 80.
3. **Keystore**: a file for the certificate, such as `ssl/letsencrypt.jks`, with a **Keystore Password** and the same as **Key Password**.
4. **Email**: an address of yours. Let's Encrypt writes to it about the account.
5. Tick **Enabled**. Press **Test**. It runs the whole exchange against Let's Encrypt's test service and tells you what went wrong, without using up your allowance of real certificates.
6. When the test is good, press **Submit**: "Only submit after a successful Test. Have you run the Test and received a successful result?" This gets the real certificate and writes it into the keystore.
7. Tick **Update the certificate automatically**, and **Save**.
8. Use the keystore on your secure ports: [SSL](Prefs-Encryption-SSL.md), or the port's own certificate in [the ports of the server](Ports.md).

## How the name is proven

Let's Encrypt gives a certificate only to whoever controls the name. **Challenge type** is how the server proves that:

| Kind | The proof | Needs |
|---|---|---|
| **http-01** | Let's Encrypt fetches a file from `http://` the name `/.well-known/acme-challenge/…`. The plugin puts the file there. | port 80 of the name reaching an HTTP port of the server, chosen under **Related CrushMFT Server Port (only http allowed)** |
| **tls-alpn-01** | Let's Encrypt connects to port 443 of the name and expects a special certificate, which the server shows for that one call | port 443 of the name reaching an HTTPS port of the server, chosen under **Related CrushMFT Server Port (only https allowed)**, with nothing in between that ends the TLS connection |
| **dns-01** | a record in the DNS zone of the name, set by a job of yours | a DNS provider that can be changed by a program: [Let's Encrypt by DNS](Plugin-LetsEncrypt-DNS.md) |
| **dns-persist-01** | a DNS record that is set once and stays | a certificate authority that offers this kind: the same page |

Which to take:

- A name for all your sub domains, `*.example.com`, can only be proven by DNS: "ACME strictly requires DNS challenges for Wildcard certificates".
- A certificate for an IP address can only be proven by http-01 or tls-alpn-01, and is always a short-lived one.
- Several servers behind one name, or DMZ servers: [Let's Encrypt in a cluster](HA-Lets-Encrypt.md).

## Settings

### The certificate

| Setting | Is | On a new server |
|---|---|---|
| **Domains** | the names the certificate is for. All of them must lead to this server; all go into one certificate. "Domains field is empty." | empty |
| **Keystore**, **Browse** | the file the certificate and its key are written to. In FIPS mode the screen says which copy is used. | empty |
| **Keystore Password**, **Key Password** | the passwords of that file and of the key in it. Use the same for both. | empty |
| **Common Name**, **Organisation Unit**, **Locality**, **State**, **Country Code** | the facts written into the request. Let's Encrypt only uses the names; the others are for authorities that show them. | empty |
| **Email** | the contact of your account at the authority | empty |
| **ACME Files Path** | where the http-01 file is put. It must be the folder the web port serves. An empty field is corrected: "The default './WebInterface/' value was applied and saved." | `./WebInterface/` |
| **Short Live** | asks for a short-lived certificate, a few days long, where the authority offers them. They need renewing often; turn automatic renewal on. | off |
| **Notes** | a text for yourself | empty |

### The authority

| Setting | Is | On a new server |
|---|---|---|
| **ACME URL** | the authority's ACME service | `acme-v02.api.letsencrypt.org` |
| **ACME Test URL** | its test service, which **Test** uses | `acme-staging-v02.api.letsencrypt.org` |
| **Load ACME Directories** | asks the **ACME URL** what it offers and shows the answer: "ACME Directory loaded successfully." A way to check an address before using it. | |
| **Request version** | **V02**, the ACME version every authority uses now. **V01** is kept for old settings. | V02 |
| **Use External Account Binding** | for authorities that tie the ACME account to an account you have with them. **EAB Key**: **KID and Key**, with the **ACME KID** and **ACME Key** the authority gave you; or **Google Cloud OAuth profile**, with an **OAuth Profile** and the **Google Cloud Project ID**, where the key is made for you each time an account is registered. Let's Encrypt does not use this. | off |
| **Use Proxy** | the calls to the authority go through a proxy: **Proxy Type**, **Proxy Host**, **Proxy Port**, **Proxy Username**, **Proxy Password** | off |
| **Log HTTP Request Calls** | every call to the authority is written to the log | off |

### Checks before asking

Before it talks to the authority, the plugin checks for itself that each name resolves and that a call to the name arrives at this server. That saves failed attempts, which authorities count.

| Setting | Is |
|---|---|
| **Ignore Failing "Not a CrushMFT Server"** | goes on although a call to the name was not answered by this server. For a name that is answered by a proxy or a balancer in front. |
| **Skip all pre-checks (DNS, CrushMFT server, etc)** | no checks at all. For the DNS kinds on a server the internet cannot reach. |

### Where the certificate goes

| Setting | Is |
|---|---|
| **Server Instance** | on a server with DMZ servers: which of them the certificate is for. Empty: this server itself. |
| **Replicate?** | the new keystore is sent to the other servers of a cluster: see [Let's Encrypt in a cluster](HA-Lets-Encrypt.md#the-spread-replicate) |

### Renewing

| Setting | Is | On a new server |
|---|---|---|
| **Update the certificate automatically** | the plugin watches the certificate and renews it in time | off |
| **Check certificate at** | the time of day of the check, as `hh:mm` | empty |
| **Check certificate every** … **days** | how often it looks. 1 to 90. | 5 |
| **Update certs before** … **days** | it renews when fewer than this many days are left | 14 |
| **Use Renewal Info** | asks the authority when it would like the certificate renewed, and follows that. If the authority cannot say, or says "wait" with only days left, the number of days above still counts. | off |
| **Update info** | what the last check found | "Last check:" |
| **Execute CrushTask/Job after cert renew** | a job that is run after each renewal, for example to copy the certificate to another machine or to tell somebody | none |

A renewal by itself always uses the real service, also when you last pressed **Test**. After it, the server starts its secure ports again with the new certificate; the server itself is not restarted. What happens when a renewal fails is in the log, on lines that start with "AUTO-UPDATE:".

## The buttons

| Button | Does |
|---|---|
| **Test** | the whole exchange, against the **ACME Test URL**. The certificate it gets is not trusted by anybody and is not put to use. |
| **Submit** | the real thing: asks the **ACME URL**, writes the certificate into the keystore |
| **ACME Key Change** | "Let's Encrypt - Key Change": gives your account at the authority a new key pair. "Account key successfully changed." For when the account's key may have been copied. It always acts on the real service. |
| **ACME Revoke Cert** | "Let's Encrypt - Revoke Cert": tells the authority to withdraw the certificate, with a **Revoke reason** such as **Key Compromise**, **Cessation Of Operation** or **Affiliation Changed**. "Certificate successfully revoked." Get a new one right after. |

## Things to know

- **Test first, always.** Authorities limit how many certificates a name gets in a week, and how many failed attempts in an hour. The test service has no such limits.
- **Port 80 must stay open** for http-01, for every renewal, not only the first time.
- **The keystore is written by the plugin.** Do not point it at a keystore that holds other certificates you need.
- **Keep the plugin's files.** The account at the authority is a key pair that the plugin keeps in files on the server. Back the server's folder up as a whole.
- **One certificate, several names**: put them all under **Domains**. For names with different owners or ports, make a second [configuration](Prefs-Plugins.md#several-configurations-of-one-plugin).
- **Let's Encrypt certificates are for 90 days.** With the usual settings the plugin renews at 14 days left; nothing reminds you if automatic renewal is off.

## Not tried for this page

No certificate was requested: the test server has no name the internet can reach. The page is written from the plugin's screen and from what the plugin's file says it does. See also [SSL certificates](Security-SSL-Certificates.md).
