how to export ssl key , crt and CA from httpd.conf apache to use it into nginx for all users

前端 未结 1 1527
情话喂你
情话喂你 2021-01-29 09:28

use custom setup that use nginx as web engine with cpanel need command to export ssl files to use it into nginx

cpanel now use AutoSSL powered by Comodo that give it fr

相关标签:
1条回答
  • 2021-01-29 10:06

    I'm sure some efficiency nuts will choke on this, but it should work:

    #!/bin/bash
    # Look for ServerName, and extract the value.  Loop over results.
    for server in $( grep ServerName httpd.conf | sed 's/.*ServerName\s*//' ); do
        echo $server
        # Pull out the block of XML for that server
        block=$( grep -A5 "$server" httpd.conf)
    
        # Extract file names from the XML block
        SSLCertificateFile=$( echo "$block" | sed -n 's/.*SSLCertificateFile\s*//p')
        SSLCertificateKeyFile=$( echo "$block" | sed -n 's/.*SSLCertificateKeyFile\s*//p')
        SSLCACertificateFile=$( echo "$block" | sed -n 's/.*SSLCACertificateFile\s*//p')
    
        # Create files
        cp "$SSLCertificateKeyFile" "${server}.key"
        cat "$SSLCertificateFile" "$SSLCACertificateFile" > "${server}.crt"
    done
    # end of loop
    
    0 讨论(0)
提交回复
热议问题