美文网首页
Openssl 自签名证书生成脚本

Openssl 自签名证书生成脚本

作者: 搬砖_工程师 | 来源:发表于2017-10-29 01:31 被阅读329次

    转自github(https://github.com/michaelliao/itranswarp.js/blob/master/conf/ssl/gencert.sh)

    #!/bin/sh
    
    # create self-signed server certificate:
    
    read -p "Enter your domain [www.example.com]: " DOMAIN
    
    echo "Create server key..."
    
    openssl genrsa -des3 -out $DOMAIN.key 1024
    
    echo "Create server certificate signing request..."
    
    SUBJECT="/C=US/ST=Mars/L=iTranswarp/O=iTranswarp/OU=iTranswarp/CN=$DOMAIN"
    
    openssl req -new -subj $SUBJECT -key $DOMAIN.key -out $DOMAIN.csr
    
    echo "Remove password..."
    
    mv $DOMAIN.key $DOMAIN.origin.key
    openssl rsa -in $DOMAIN.origin.key -out $DOMAIN.key
    
    echo "Sign SSL certificate..."
    
    openssl x509 -req -days 3650 -in $DOMAIN.csr -signkey $DOMAIN.key -out $DOMAIN.crt
    
    echo "TODO:"
    echo "Copy $DOMAIN.crt to /etc/nginx/ssl/$DOMAIN.crt"
    echo "Copy $DOMAIN.key to /etc/nginx/ssl/$DOMAIN.key"
    echo "Add configuration in nginx:"
    echo "server {"
    echo "    ..."
    echo "    listen 443 ssl;"
    echo "    ssl_certificate     /etc/nginx/ssl/$DOMAIN.crt;"
    echo "    ssl_certificate_key /etc/nginx/ssl/$DOMAIN.key;"
    echo "}"
    

    相关文章

      网友评论

          本文标题:Openssl 自签名证书生成脚本

          本文链接:https://www.haomeiwen.com/subject/wemepxtx.html