Skip to content

TLS Certificates

After a renewal or migration, most "the service will not start" tickets are certificate issues. Wrong file, wrong chain, key does not match, key unreadable, or expired.

Set the paths once for the commands below:

CERT=/etc/rstudio-connect/connect.example.com.crt
KEY=/etc/rstudio-connect/connect.example.com.key

1. Read the certificate

openssl x509 -in "$CERT" -noout -subject -issuer -dates -ext subjectAltName

Check:4

  • notAfter is in the future (and not soon)
  • subjectAltName includes every name users type (for example connect.example.com). Modern clients ignore the CN.
  • The issuer is the CA you expect

Days until expiry:

openssl x509 -in "$CERT" -noout -checkend $((30*86400)) && echo "valid for 30+ days" || echo "expires within 30 days"

2. Check the private key

sudo openssl pkey -in "$KEY" -noout -check

If it prompts for a passphrase, the key is encrypted.5 Posit products cannot use encrypted keys.123 Remove the passphrase (store the result securely):

sudo openssl pkey -in encrypted.key -out "$KEY"

3. Confirm certificate and key match

Compare public keys. This works for RSA and EC keys alike:45

openssl x509 -in "$CERT" -noout -pubkey | openssl sha256
sudo openssl pkey -in "$KEY" -pubout | openssl sha256

The two hashes must be identical. (The older -modulus | md5 comparison only works for RSA keys.)

4. Check the chain

If the certificate comes from an internal CA, the file should contain the server certificate first, then intermediates. Count the certificates in the file:

grep -c 'BEGIN CERTIFICATE' "$CERT"

Verify against the system trust store, or against an explicit CA bundle:6

openssl verify -untrusted "$CERT" "$CERT"
openssl verify -CAfile /etc/pki/tls/certs/ca-bundle.crt -untrusted "$CERT" "$CERT"

5. Test the live service

From another host:

openssl s_client -connect connect.example.com:443 -servername connect.example.com </dev/null 2>/dev/null | openssl x509 -noout -subject -dates
```[^openssl-s_client]

```bash
curl -vI https://connect.example.com 2>&1 | grep -E 'SSL|subject|expire|HTTP/'

Look for Verify return code: 0 (ok) in full s_client output. A verify error from a client host that does not trust your internal CA is a client trust store issue, not a server issue.

6. Ownership and permissions

File Mode Owner
Certificate (Workbench) 0644 rstudio-server:rstudio-server
Key (Workbench) 0600 rstudio-server:rstudio-server
Certificate (Connect) 0644 rstudio-connect:rstudio-connect
Key (Connect) 0600 rstudio-connect:rstudio-connect
Certificate (Package Manager) 0644 rstudio-pm:rstudio-pm
Key (Package Manager) 0600 rstudio-pm:rstudio-pm

Each product reads its own certificate and key, so ownership follows the service account, not root.123

Check every directory on the path, not just the file. A readable key inside an unreadable directory is still unreadable:

sudo namei -l "$KEY"

/etc/ssl/private is commonly restricted to root or a dedicated ssl-cert group rather than the product's service account. Debian and Ubuntu ship it as 0710 root:ssl-cert, which does not include rstudio-server, rstudio-connect, or rstudio-pm.8 Rather than adding the service account to that group, keep each product's key in its own config directory. For example, Posit recommends /etc/rstudio-pm/ for Package Manager.123

SELinux preserves a file's existing label across mv within the same filesystem; only cp (without --preserve=context) picks up a fresh label from the destination directory's default policy.9 Restore the default labels after placing files:

bash sudo restorecon -Rv /etc/rstudio-pm /etc/rstudio-connect /etc/rstudio9

Summary

Check Command
Validity, SANs, issuer openssl x509 -noout -subject -issuer -dates -ext subjectAltName
Key integrity openssl pkey -noout -check
Cert and key match Compare -pubkey hashes
Chain openssl verify -untrusted
Live endpoint openssl s_client, curl -vI
Permissions on whole path namei -l

The posit-workbench, posit-connect, and posit-pm scripts check the subject, issuer, and expiry of each certificate their product is configured with. Matching the private key needs root, so they print that command for your sudo administrator.