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

走远了吗. 提交于 2019-12-02 13:14:56

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!