Apache 配置https 自簽名證書 或者 購賣證書

大飛_dafei發表於2019-02-13

購賣證照配置

<VirtualHost _default_:443>
    SSLProtocol all -SSLv2 -SSLv3
    SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
    SSLHonorCipherOrder on
    SSLCertificateFile       /data/server/apache/conf/extra/cert/a_public.crt
    SSLCertificateKeyFile    /data/server/apache/conf/extra/cert/a.key
    SSLCertificateChainFile  /data/server/apache/conf/extra/cert/a_chain.crt

    ServerName 你的域名:443
    DocumentRoot "/data/web/web01/"
    <Directory /data/web/web01/>
        Options FollowSymlinks
        DirectoryIndex index.php
        Allow from all
        AllowOverride All
        Require all granted
    </Directory>
    SSLEngine on
    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory "/data/server/apache/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    CustomLog "/data/server/apache/logs/ssl_request_log" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>

自簽名證照

利用 openssl 自己生成

#私鑰
openssl genrsa -out server.key 2048

#自簽名證照
openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt -extensions usr_cert
執行後,遇到 Common Name (e.g. server FQDN or YOUR name) []:  填寫你需要的域名或者ip


-----------------
openssl genrsa -out 127_0_0_1_server.key 2048
openssl req -new -x509 -nodes -sha1 -days 3650 -key 127_0_0_1_server.key -out 127_0_0_1_server.crt -extensions usr_cert

其他參考地址:  

Apache 2.4自簽名證照及客戶端SSL認證

Apache2.4.7配置Https

OpenSSL命令詳解

相關文章