Hosting + Ai Website Builder + Free Domain (3 Month Free Credit)
Shop Today

How to Fix TLS on Linux Server: Complete Troubleshooting Guide

Transport Layer Security (TLS) is a cryptographic protocol used to secure communication over a computer network. Administrators may need to fix TLS issues to ensure secure encryption between clients and servers, especially for HTTPS (HTTP over TLS). TLS ensures that data remains confidential, authentic, and intact during transmission. However, issues with TLS configurations, certificates, or services can lead to connection problems or security vulnerabilities.

In this guide, we will walk you through common issues related to TLS on Linux servers, from configuration errors to certificate issues, and provide solutions to fix them. Whether you’re facing problems with TLS connections, certificate configurations, or outdated protocols, this guide will help you get things back on track.

Preliminary Steps Before Fixing TLS

How to Fix TLS on Linux Server

Before diving into specific fixes, make sure your server is properly configured and has the necessary packages installed to support TLS encryption.

TLS is most commonly used with web servers like Apache or NGINX. Ensure that your web server (Apache or NGINX) is installed and running correctly. You can check the status of these services using the following commands:

For Apache:

sudo systemctl status apache2

For NGINX:

sudo systemctl status nginx

If the web server is not running, restart it:

For Apache:

sudo systemctl restart apache2

For NGINX:

sudo systemctl restart nginx

Verify OpenSSL Installation

OpenSSL is essential for implementing TLS on Linux servers. Verify that OpenSSL is installed by checking its version:

openssl version

If OpenSSL is not installed, you can install it using the following commands:

For Debian/Ubuntu-based systems:

sudo apt-get install openssl

For RHEL/CentOS-based systems:

sudo yum install openssl

Ensure Correct Time and Date

TLS certificates rely on accurate timestamps to ensure they are valid and not expired. Ensure your server’s time and date are set correctly. To check the system time:

date

If the time is incorrect, you can synchronize your server’s time with NTP (Network Time Protocol):

sudo apt-get install ntp  # On Debian/Ubuntu-based systems
sudo systemctl enable ntp
sudo systemctl start ntp

For RHEL/CentOS-based systems:

sudo yum install ntp
sudo systemctl enable ntpd
sudo systemctl start ntpd

Identifying Common TLS Issues

Several issues can arise with TLS on a Linux server, including misconfigurations, outdated protocols, or certificate-related problems. Below are some common problems and their causes:

  • TLS Connection Issues (Handshake Failures)

Handshake failures occur when the server and client cannot agree on a secure protocol or cipher suite to use. This can be caused by outdated TLS configurations or unsupported protocol versions.

  • Expired or Invalid TLS Certificates

TLS certificates may expire or become invalid, leading to errors like “certificate expired” or “certificate not trusted.”

  • Weak or Insecure TLS Protocol Versions (SSLv3, TLS 1.0, TLS 1.1)

Using old or insecure versions of TLS (such as TLS 1.0 or 1.1) makes your server vulnerable to various attacks. Modern browsers and clients typically prefer TLS 1.2 or TLS 1.3.

  • Certificate Chain Issues

If a server’s TLS certificate cannot be verified due to a missing intermediate certificate, clients may receive errors like “certificate chain incomplete.”

  • Insecure Ciphers

If your server is configured to use weak ciphers, it can expose your site to attacks. This is often seen in older TLS configurations.

Fixing TLS on Linux Server: Step-by-Step Solutions

Once you’ve identified the issue, follow these troubleshooting steps to resolve it.

Check the TLS Version Configured in Your Web Server

Ensure that your web server is configured to support modern versions of TLS (1.2 and 1.3). Older protocols like SSLv3, TLS 1.0, and TLS 1.1 should be disabled for security reasons.

For Apache:

  • Open the Apache SSL configuration file (typically located in /etc/apache2/sites-available/default-ssl.conf or /etc/httpd/conf.d/ssl.conf).
sudo nano /etc/apache2/sites-available/default-ssl.conf
  • Look for the SSLProtocol directive and ensure it is set to only allow TLS 1.2 and TLS 1.3:
SSLProtocol TLSv1.2 TLSv1.3
  • Restart Apache to apply the changes:
sudo systemctl restart apache2

For NGINX:

  • Open the NGINX SSL configuration file (usually located in /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf).
sudo nano /etc/nginx/nginx.conf
  • Look for the ssl_protocols directive and ensure that it is configured to use TLS 1.2 and 1.3 only:
ssl_protocols TLSv1.2 TLSv1.3;
  • Restart NGINX:
sudo systemctl restart nginx

Disable Insecure Ciphers

In addition to ensuring that only modern TLS versions are enabled, you should also disable weak or insecure ciphers.

For Apache:

  • Open the SSL configuration file (/etc/apache2/sites-available/default-ssl.conf or /etc/httpd/conf.d/ssl.conf).
sudo nano /etc/apache2/sites-available/default-ssl.conf
  • Add or modify the SSLCipherSuite directive to use strong ciphers only:
SSLCipherSuite HIGH:!aNULL:!MD5:!3DES

This configures Apache to use strong ciphers and avoid weaker algorithms.

  • Restart Apache to apply the changes:
sudo systemctl restart apache2

For NGINX:

  • Open the NGINX SSL configuration file:
sudo nano /etc/nginx/nginx.conf
  • Modify or add the following line under the server block to use strong ciphers:
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384';
  • Restart NGINX:
sudo systemctl restart nginx

Renew Expired or Invalid Certificates

If your TLS certificates are expired or invalid, you’ll need to renew or replace them. If you’re using Let’s Encrypt, run the following command to renew your certificate:

sudo certbot renew

If you’re using a paid certificate or a self-signed certificate, download the new certificate files and replace the old ones. Update your web server configuration to point to the new certificate files.

For Apache, update the certificate paths in /etc/apache2/sites-available/default-ssl.conf:

SSLCertificateFile /path/to/new/certificate.crt
SSLCertificateKeyFile /path/to/new/private.key
SSLCertificateChainFile /path/to/new/chainfile.pem

For NGINX, update the certificate paths in your NGINX configuration file:

ssl_certificate /path/to/new/certificate.crt;
ssl_certificate_key /path/to/new/private.key;
ssl_trusted_certificate /path/to/new/chainfile.pem;

After updating the certificate, restart the web server:

For Apache:

sudo systemctl restart apache2

For NGINX:

sudo systemctl restart nginx

Check the Certificate Chain

If the browser is showing a “certificate chain incomplete” error, it means your server is not serving the intermediate certificates, which help clients trust the SSL certificate. Ensure you have configured the certificate chain correctly.

For Apache, check that the SSLCertificateChainFile directive points to the correct intermediate certificate file:

SSLCertificateChainFile /path/to/intermediate.pem

For NGINX, ensure the ssl_trusted_certificate points to the correct intermediate certificate:

ssl_trusted_certificate /path/to/intermediate.pem;

After updating, restart your web server.

Test TLS Configuration

Once you’ve made changes to your TLS configuration, it’s essential to test that everything is working properly.

  • Test SSL/TLS Connection: Use openssl to check if the server supports TLS and the correct cipher suites:
openssl s_client -connect yourdomain.com:443
  • Test TLS Strength:

Use the SSL Labs SSL Test to check the security rating of your TLS configuration. Go to SSL Labs SSL Test and enter your domain to check for any potential issues with your TLS/SSL configuration.

    Verify SSL/TLS Certificates sslyze

    sslyze is a great tool to test your server’s SSL/TLS configuration. You can install it and run a diagnostic:

    • Install sslyze:
    sudo apt-get install sslyze  # Debian/Ubuntu
    • Test your server:
    sslyze --regular yourdomain.com

    This tool will give you detailed information on your server’s TLS configuration, including the supported protocols and ciphers.

    Conclusion

    Fixing TLS on a Linux server involves troubleshooting common issues like misconfigurations, expired certificates, weak ciphers, and improper network settings. By following the troubleshooting steps outlined in this guide, you can secure your server with up-to-date TLS configurations, renew or replace certificates, and ensure secure communications. Regularly monitor and test your TLS settings to ensure the continued security of your server and client data.

    Himanshu Joshi

    Leave a Comment

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

    Scroll to Top