Custom SSL Certificate in Tomato

In this article we are going to detail the steps required to enable a Custom SSL certificate for the Web Interface of most Tomato variants of router firmware. In order to complete this task, we must enable SSH on our router. This can be accomplished by navigating to “Administration > Admin Access > SSH Server“. Please ensure the option “Allow Password Login” is enabled and the SSH server is running. Once those steps are complete, your can login to your router via ssh as root user. Note the root password is the same password used to login to the Web Interface.

ssh root@[router-ip-address]
# Setting a Custom HTTPS certificate in Tomato, AdvancedTomato, or FreshTomato

# Set Working Director
cd /etc/

# Backup Old Certificate & Key
mv /etc/cert.pem /etc/cert.pem.bkp
mv /etc/key.pem /etc/key.pem.bkp

# Create New Certifcate
cat << EOF > /etc/cert.pem
... Paste Certificate Data Here
EOF

# Create New Key
cat << EOF > /etc/key.pem
... Paste Key Data Here
EOF

# Enable New Certificate & Key
nvram set https_crt_save=0

tar -C / -czf /tmp/cert.tgz etc/cert.pem etc/key.pem
nvram set https_crt_file="$(/usr/sbin/openssl enc -base64 < /tmp/cert.tgz | tr -d '\n')"

nvram set https_crt_save=1
service httpd restart

# Commit Changes & Restart
nvram commit
service httpd restart

# If Successful Remove Old Certificate & Key
rm /etc/cert.pem.bkp /etc/key.pem.bkp

Congratulations, if everything went well, your router web interface should now be using your Custom SSL Certificate.

Did you find this article useful? Why not share it with your friends?

Leave a Reply

Your email address will not be published. Required fields are marked *