Overview
Ant Media Server provides built-in SSL/TLS support for secure HTTPS and RTMPS connections. Theenable_ssl.sh script automates certificate installation using Let’s Encrypt or custom certificates.
SSL Setup Methods
Ant Media Server supports three SSL configuration methods:- Free Domain with Let’s Encrypt - Enterprise users get a free subdomain (*.antmedia.cloud)
- Custom Domain with Let’s Encrypt - Use your own domain with free SSL certificate
- Custom Certificate - Install SSL certificate from your certificate provider
Prerequisites
System Requirements
- Ant Media Server installed at
/usr/local/antmedia - Root or sudo access
- Required packages:
jq,dnsutils/bind-utils,iptables,certbot
Network Requirements
- Port 80 (TCP) - Required for Let’s Encrypt HTTP-01 challenge
- Port 443 or 5443 (TCP) - HTTPS traffic
- Domain must be pointed to your server’s public IP
Domain Configuration
For custom domains, create an A record pointing to your server:Method 1: Free Domain (Enterprise Only)
Automatic Free Subdomain
Run SSL Script
Subdomain Assignment
- Generate a random subdomain:
ams-XXXXX.antmedia.cloud - Register it with Ant Media’s DNS service
- Wait for DNS propagation
- Install Let’s Encrypt certificate automatically
Verification
How It Works
Fromenable_ssl.sh:232-268:
Method 2: Custom Domain with Let’s Encrypt
Standard Installation
Point Domain to Server
Run SSL Script with Domain
Certificate Installation
- Install
certbotand dependencies - Request certificate from Let’s Encrypt
- Create keystore and truststore for RTMPS
- Configure Ant Media Server
- Set up auto-renewal cron job
- Restart the service
Verify SSL
DNS Validation (Route53)
For domains behind firewalls or when port 80 is unavailable:Manual DNS Challenge
For custom DNS providers:Method 3: Custom SSL Certificate
Using Your Own Certificate
If you have SSL certificate files from a certificate authority:Prepare Certificate Files
fullchain.pem- Full certificate chainprivkey.pem- Private keychain.pem- Intermediate certificate chain
Install Certificate
Verify Installation
- Keystore at
/usr/local/antmedia/conf/keystore.jks - Truststore at
/usr/local/antmedia/conf/truststore.jks - Copies PEM files to
/usr/local/antmedia/conf/
SSL Script Options
Command-Line Parameters
Usage Examples
What the Script Does
Certificate Installation Process
Fromenable_ssl.sh:364-455, the script performs:
Install Dependencies
- Ubuntu/Debian:
certbot,python3-certbot-dns-route53,cron,jq,dnsutils - CentOS/Rocky/AlmaLinux:
certbot,jq,bind-utils
Request Certificate
Create Java Keystores
Configure Server
Set Up Auto-Renewal
Restart Service
Certificate Files Location
Let’s Encrypt Certificates
Ant Media Server Configuration
Configuration Files
SSL settings inred5.properties:
Certificate Renewal
Automatic Renewal
The script sets up automatic renewal via cron:Manual Renewal
To manually renew:Test Renewal
Test renewal without actually renewing:Docker Deployments
SSL in Docker Containers
Ensure Port 80 is Available
Execute SSL Script in Container
Persist Certificates
kill -HUP 1 instead of systemctl.Troubleshooting
Port 80 is in Use
Error: “Port 80 is currently in use” Solution:Domain Not Resolving
Error: DNS validation failure Solution:Certificate Already Exists
Error: Certificate with the name already exists Solution:Keystore Password Issues
The script uses the domain name as the keystore password:red5.properties:
Permission Errors
RTMPS Not Working
Verify RTMPS configuration:Security Best Practices
Use Strong Passwords
Restrict File Permissions
Monitor Certificate Expiration
Use HTTPS Redirects
