Generating a CSR and Installing SSL on AWS AMI Linux Instance

Author:Vishal Singh
Updated:Jun 8, 2025

To install an SSL certificate on your Amazon AMI Linux instance, follow these organized steps:

  1. Generate CSR and Private Key:

    • Create a configuration file (example.com.cnf) with your domain details.
    echo '[NewRequest]' > example.com.cnf
    echo 'Subject = "/C=US/ST=CA/L=Mountain View/O=My Company/OU=IT/CN=myserver"' >> example.com.cnf
    echo 'Exportable = TRUE' >> example.com.cnf
    echo 'KeyLength = 2048' >> example.com.cnf
    echo 'KeySpec = 1' >> example.com.cnf
    echo 'KeyUsage = 0xf0' >> example.com.cnf
    echo 'MachineKeySet = TRUE' >> example.com.cnf
    
    • Generate the CSR and private key:
    openssl req -key privateKey.pem -out csr.pem -reqext -config example.com.cnf
    
  2. Submit CSR to Certificate Authority (CA):

    • Upload csr.pem to your CA provider (e.g., Esadax) to obtain certificate files.
  3. Combine Certificate and Private Key:

    cat privateKey.pem certificate.pem > server.crt
    
  4. Install SSL Certificate on Linux Instance:

    • Create a temporary key for installation:
    sudo openssl x509 -req -in server.crt -key -out temp.pem -days 365 -nodes
    
    • Ensure the temp key is securely managed and removed after use.
  5. Set Permissions:

    chmod 600 privateKey.pem
    chmod 600 temp.pem
    
  6. Restart Relevant Services:

    • For Nginx: sudo nginx -s reload
    • For Apache: sudo systemctl reload apache2
  7. Verify SSL Installation:

    • Use openssl s_client to check the certificate and ensure it's trusted.