TLS Certificates

TLS Certificates

This page describes the TLS certificates of Centova Cast: how Centova Cast gets them, how it renews them, and how you configure them. The control panel uses a TLS certificate for HTTPS. The streaming servers use TLS certificates for the HTTPS links of the streams.

You manage the certificates of the streaming hostnames on the Hostnames page of the control panel. For the description of that page, see the Hostnames section. This page describes the functions that you configure on the server: the certificate of the control panel, the validation of hostnames, and the renewal of certificates. The validation of hostnames includes the DNS validation for wildcard hostnames.

Hostnames and Certificates

Centova Cast keeps a list of hostnames. Each hostname has one or more purposes:

  • Web interface
    Users open the control panel with this hostname.

  • Streaming
    Listeners connect to the streams with this hostname.

Each hostname has a TLS certificate. One certificate can cover more than one hostname. All of the hostnames of the control panel share one certificate.

The installer creates the hostname of the control panel from its --hostname option. If no other streaming hostname exists, Centova Cast also makes the hostname of the control panel available for the streams. The streams then use the same certificate as the control panel.

You add more streaming hostnames on the Hostnames page. Resellers can add streaming hostnames for themselves and for their clients.

Certificate Types

Centova Cast supports three certificate types:

  • Self-signed certificate
    Centova Cast generates the certificate itself. A self-signed certificate is valid for one year. Centova Cast renews it automatically. Web browsers and media players do not trust a self-signed certificate, and show an error message for it. Use a self-signed certificate only for tests, or until you install a different certificate.

  • ACME certificate
    Centova Cast gets the certificate from a certificate authority (CA) through the ACME protocol, and renews it automatically. The default CA is Let's Encrypt (letsencrypt.org), a nonprofit CA that gives certificates free of charge. Web browsers and media players trust these certificates. The CA must make sure that you control each hostname before it issues a certificate. This check is the "validation" of the hostname.

  • Custom certificate
    You buy the certificate from a CA and give it to Centova Cast. Centova Cast cannot renew a custom certificate. Before it expires, you must get a new certificate from the CA and install it.

The certificate files are in etc/ssl of the installation directory:

  • etc/ssl/managed - the self-signed certificates.
  • etc/ssl/acme - the ACME certificates, and the account of Centova Cast at the CA.
  • etc/ssl/certs - the custom certificates.
  • etc/ssl/ui - a copy of the certificate of the control panel (ui.crt) and of its key (ui.key), which the web server of Centova Cast uses.

Do not change the files in these directories yourself, except as this page tells you.

The Certificate of the Control Panel

Two keys in the web-service block of castd.conf set the hostname and the certificate type of the control panel:

  • hostname
    Specifies the hostname of the control panel. To give the control panel more than one hostname, separate the hostnames with spaces, for example hostname "cast.example.com" "panel.example.com". All of these hostnames share one certificate.

  • tls-method
    Specifies the certificate type of the control panel. The values are:

    • acme
      An ACME certificate from Let's Encrypt.

    • self
      A self-signed certificate.

    • custom
      A custom certificate.

The installer sets these keys. With the default installer options, tls-method is acme. With the --no-letsencrypt option, it is self.

Centova Cast applies these keys each time it starts. It creates the hostnames of the control panel that are not in its list, and removes the Web interface purpose from hostnames that are no longer in hostname. Then it sets the certificate type of the control panel to the type of tls-method.

Note that tls-method has priority over the Hostnames page. If you change the certificate type of the control panel on the Hostnames page, also change tls-method to the same type. If you do not, Centova Cast sets the type back to tls-method the next time it starts.

Changing the Certificate of the Control Panel

To change the hostname or the certificate type of the control panel:

  1. Open /usr/local/centovacast/etc/castd.conf in a text editor.
  2. In the web-service block, change hostname, or tls-method, or both.
  3. Save the file.
  4. Restart the Centova Cast daemon:

    ~~~ {.bash} systemctl restart cc-castd ~~~

If you change the hostname, also change the server_name line in etc/cc-web-local.conf. For more information, see the Configuration File section.

Before you change tls-method to acme, make sure that the hostname points to the server in DNS, and that Centova Cast can validate it. For more information, see the Validation of Hostnames section.

Custom Certificate for the Control Panel

To use a custom certificate for the control panel:

  1. Get the certificate for the hostname of the control panel from your CA. You need the certificate chain and the private key, in PEM format.
  2. Copy the certificate chain to /usr/local/centovacast/etc/ssl/ui/ui.crt.
  3. Copy the private key to /usr/local/centovacast/etc/ssl/ui/ui.key.
  4. In castd.conf, set tls-method custom in the web-service block.
  5. Restart the Centova Cast daemon with systemctl restart cc-castd.
  6. Tell the web server of Centova Cast to read the new certificate with systemctl reload cc-web.

<!-- QUESTION: castd.conf says to put a custom web interface certificate in etc/ssl/ui/ui.crt and ui.key, but the certificate manager looks for a custom certificate in etc/ssl/certs/NAME.pem and NAME.key (certtype/custom.go:20-22, check.go:28-76). With only ui.crt/ui.key present, the daily check reports an error for the certificate and emails the owner. Is the castd.conf procedure correct, or must the administrator upload the certificate on the Hostnames page? -->

Before the certificate expires, install the new certificate in the same way (steps 1 to 3 and 6).

Let's Encrypt at Installation

By default, the installer gets a Let's Encrypt certificate for the hostname of its --hostname option. For this:

  • The hostname must point to the IP address of the server in DNS. If you give the --bind option, the hostname must point to that IP address. If you do not, it must point to the primary IP address of the server. If IPv6 is enabled on the server, the hostname must also point to the primary IPv6 address of the server.
  • Port 80 of the server must be free and reachable from the Internet. During the installation, the installer starts a temporary web server on port 80 for the validation.
  • The control panel must use port 80 for HTTP. The installer refuses --no-webports, and --ports with an HTTP port other than 80, unless you also give --no-letsencrypt.

These installer options concern the certificate:

  • --email=EMAIL
    Specifies the email address of the administrator. The installer also uses it for the registration with Let's Encrypt, unless you give --le-email.

  • --le-email=EMAIL
    Specifies a different email address for the registration with Let's Encrypt.

  • --le-staging
    Gets the certificate from the staging servers of Let's Encrypt. A staging certificate is not trusted. Later ACME certificates also come from the staging servers.

  • --no-letsencrypt
    Gives the control panel a self-signed certificate.

If the installer cannot get the certificate, it stops. You can then install with --no-letsencrypt, and change to an ACME certificate later. For the details of the installation, see the Installation Manual.

Validation of Hostnames

Before the CA issues an ACME certificate, it makes sure that you control each hostname of the certificate. Centova Cast supports two validation methods.

HTTP Validation

The CA connects to port 80 of the hostname and asks for a file below /.well-known/acme-challenge/. The web server of Centova Cast gives the file to the CA. Centova Cast uses HTTP validation for all hostnames except wildcard hostnames.

HTTP validation is available only if the control panel uses port 80, that is, if the http-port key of the web-service block in castd.conf contains 80. If it is not available, the Hostnames page does not offer the ACME certificate type.

DNS Validation (Wildcard Hostnames)

A wildcard hostname, for example *.example.com, gives each client account a hostname of its own, made from its username. Let's Encrypt issues a certificate for a wildcard hostname only after a DNS validation. For a DNS validation, Centova Cast adds a temporary record to the DNS zone of the hostname through the interface of your DNS provider. Centova Cast uses the lego program for this.

Without DNS validation, the Hostnames page refuses an ACME certificate for a wildcard hostname. You can then use a self-signed or a custom certificate for it.

To configure DNS validation:

  1. Install the lego package:

    ~~~ {.bash} /usr/local/centovacast/sbin/install lego ~~~

  2. Find the lego code of your DNS provider and the names of its credential variables. To show the list of providers, type:

    ~~~ {.bash} /usr/local/centovacast/bin/lego dnshelp ~~~

    To show the variables of one provider, for example Cloudflare, type:

    ~~~ {.bash} /usr/local/centovacast/bin/lego dnshelp -c cloudflare ~~~

  3. Create the credentials file from the sample file. Make it readable only by root and the centovacast group:

    ~~~ {.bash} cd /usr/local/centovacast/etc cp acme-dns.env.sample acme-dns.env chown root:centovacast acme-dns.env chmod 0640 acme-dns.env ~~~

  4. Open acme-dns.env in a text editor. Set the credential variables of your provider, one on each line, in the form NAME=value. For example, for Cloudflare:

    ~~~ CLOUDFLARE_DNS_API_TOKEN=your-api-token ~~~

  5. In the advanced block of castd.conf, set the provider code:

    ~~~ tls.acme.dns.provider "cloudflare" ~~~

  6. Restart the Centova Cast daemon with systemctl restart cc-castd.

You can now select Free certificate via letsencrypt.org for a wildcard hostname on the Hostnames page.

CAUTION: Keep acme-dns.env readable only by root and the centovacast group. The credentials in this file can change the DNS records of your domains.

If the CA cannot see the temporary DNS record, the validation fails. By default, lego asks the DNS resolvers of the server whether the record is visible before it tells the CA to validate. To use other DNS resolvers for this check, set tls.acme.dns.resolvers.

These keys of the advanced block in castd.conf control DNS validation. If a key is not in the block, Centova Cast uses its default value. After a change, restart the Centova Cast daemon with systemctl restart cc-castd.

  • tls.acme.dns.provider
    Specifies the lego code of the DNS provider for DNS validation, for example cloudflare. If this key is not set, DNS validation is not available. There is no default.

  • tls.acme.dns.env-file
    Specifies the file with the credentials of the DNS provider. Keep this file readable only by root and the centovacast group. The default is etc/acme-dns.env in the installation directory.

  • tls.acme.dns.program
    Specifies the path of the lego program. The lego package installs it. If the program does not exist, DNS validation is not available. The default is bin/lego in the installation directory.

  • tls.acme.dns.resolvers
    Specifies the DNS resolvers, in the form host:port, that lego asks to make sure that the temporary DNS record is visible. To give more than one, separate them with spaces in one quoted value, for example tls.acme.dns.resolvers "192.0.2.53:53 198.51.100.53:53". If this key is not set, lego uses the DNS resolvers of the server.

Renewal

Centova Cast examines all of the certificates once every 24 hours. It generates a certificate again if one of these conditions is true:

  • The certificate file or the key file does not exist or cannot be read.
  • The certificate does not contain exactly the hostnames that the certificate has on the Hostnames page. For example, you added a hostname to the certificate.
  • The certificate expires in 30 days or less.

The renewal depends on the certificate type:

  • Self-signed certificate
    Centova Cast generates a new certificate, valid for one year.

  • ACME certificate with HTTP validation
    Centova Cast asks the CA for its renewal information (ACME Renewal Information, ARI). If the CA suggests a renewal time that is later, Centova Cast postpones the renewal, and examines the certificate again the next day. Otherwise, it renews the certificate. The renewal information can only postpone a renewal. Centova Cast never renews a certificate when more than 30 days remain before its expiry date. If the CA does not give renewal information, Centova Cast renews the certificate.

  • ACME certificate with DNS validation
    Centova Cast renews the certificate through lego as soon as the certificate expires in 30 days or less.

  • Custom certificate
    Centova Cast cannot renew the certificate. It sends a reminder email each day until you install a new certificate.

When a renewal fails, Centova Cast records the time and the error message. The Hostnames page shows them in the Certificate Status column. Centova Cast tries again the next day. After you correct the cause, click Retry on the Hostnames page to try again immediately.

Example: Let's Encrypt issues a certificate that is valid for 90 days, on 1 March. From 1 March to 30 April, Centova Cast does not renew the certificate. On 1 May, 30 days remain. Centova Cast asks Let's Encrypt for its renewal information. Let's Encrypt suggests a renewal between 3 May and 5 May, so Centova Cast postpones the renewal. On 3 May, the suggested renewal period starts, and Centova Cast renews the certificate.

After a Renewal

After it generates a certificate again, Centova Cast does these steps:

  • For a streaming hostname, it gives the new certificate to each account that uses the hostname, and reloads the streaming servers of these accounts that run. The streams continue.
  • For the hostname of the control panel, it tells the web server to read the new certificate. A scheduled job reloads the web server within 5 minutes.

Email Messages

Centova Cast sends these email messages about certificates to the owner of the hostname. You can change their text on the Emails page. For more information, see the Email Management section.

  • TLS certificate creation error
    Centova Cast could not create a new certificate.

  • TLS certificate expires soon
    Centova Cast could not renew a certificate, or the certificate is a custom certificate that is near its expiry date. The message includes the error, if there is one.

  • TLS certificate renewed
    Centova Cast renewed a certificate.

  • Server reload required
    Centova Cast renewed a certificate, but could not reload the streaming server of an account. The stream uses the old certificate until its streaming server restarts.

The ACME Account

Centova Cast registers an account at the CA, and keeps it in etc/ssl/acme. The account has an email address, to which the CA can send messages about your certificates. If you gave the --le-email option to the installer, Centova Cast uses that email address. If you did not, it uses the email address for notifications from the Settings page. The installer sets the email address for notifications from its --email option.


Previous: Configuration File
Section: Advanced
Next: Uninstalling