Skip to main content

Overview

Ant Media Server provides built-in SSL/TLS support for secure HTTPS and RTMPS connections. The enable_ssl.sh script automates certificate installation using Let’s Encrypt or custom certificates.

SSL Setup Methods

Ant Media Server supports three SSL configuration methods:
  1. Free Domain with Let’s Encrypt - Enterprise users get a free subdomain (*.antmedia.cloud)
  2. Custom Domain with Let’s Encrypt - Use your own domain with free SSL certificate
  3. 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 must be available for Let’s Encrypt validation. The script will check if port 80 is in use and fail if blocked.
  • 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:
Verify DNS propagation:

Method 1: Free Domain (Enterprise Only)

This method is available only for Ant Media Server Enterprise Edition users or marketplace deployments.

Automatic Free Subdomain

1

Run SSL Script

Execute the script without parameters to get a free subdomain:
2

Subdomain Assignment

The script will:
  • 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
3

Verification

Once complete, access your server:

How It Works

From enable_ssl.sh:232-268:

Method 2: Custom Domain with Let’s Encrypt

Standard Installation

1

Point Domain to Server

Configure your DNS A record to point to your server’s public IP address.
2

Run SSL Script with Domain

With email notification:
3

Certificate Installation

The script will:
  • Install certbot and 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
4

Verify SSL

Access your server:

DNS Validation (Route53)

For domains behind firewalls or when port 80 is unavailable:
Ensure AWS credentials are configured with Route53 permissions before using DNS validation.

Manual DNS Challenge

For custom DNS providers:
Follow the prompts to add TXT records to your DNS.

Method 3: Custom SSL Certificate

Using Your Own Certificate

If you have SSL certificate files from a certificate authority:
1

Prepare Certificate Files

You need three files:
  • fullchain.pem - Full certificate chain
  • privkey.pem - Private key
  • chain.pem - Intermediate certificate chain
2

Install Certificate

3

Verify Installation

The script creates:
  • 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

From enable_ssl.sh:364-455, the script performs:
1

Install Dependencies

Installs required packages:
  • Ubuntu/Debian: certbot, python3-certbot-dns-route53, cron, jq, dnsutils
  • CentOS/Rocky/AlmaLinux: certbot, jq, bind-utils
2

Request Certificate

Uses certbot to obtain certificate:
3

Create Java Keystores

Converts PEM files to JKS format for RTMPS:
4

Configure Server

Updates configuration files:
5

Set Up Auto-Renewal

Creates cron job for certificate renewal:
6

Restart Service

Restarts Ant Media Server to apply changes:

Certificate Files Location

Let’s Encrypt Certificates

Ant Media Server Configuration

Configuration Files

SSL settings in red5.properties:

Certificate Renewal

Automatic Renewal

The script sets up automatic renewal via cron:
Certificates are renewed every 85 days at 3:00 AM.

Manual Renewal

To manually renew:

Test Renewal

Test renewal without actually renewing:

Docker Deployments

SSL in Docker Containers

1

Ensure Port 80 is Available

Map port 80 for Let’s Encrypt validation:
2

Execute SSL Script in Container

3

Persist Certificates

Mount certificate directory:
In Docker, the service restart happens via kill -HUP 1 instead of systemctl.

Troubleshooting

Port 80 is in Use

Error: “Port 80 is currently in use” Solution:
Alternatively, use DNS validation:

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:
If you need to change it, update red5.properties:

Permission Errors

RTMPS Not Working

Verify RTMPS configuration:

Security Best Practices

1

Use Strong Passwords

Although the script uses domain name as password, for production, consider custom passwords:
2

Restrict File Permissions

3

Monitor Certificate Expiration

Set up monitoring for certificate expiration:
4

Use HTTPS Redirects

Configure your load balancer or reverse proxy to redirect HTTP to HTTPS.

Wildcard Certificates

For wildcard certificates (*.yourdomain.com):

Next Steps