apache2 以及https證書配置


環境Ubuntu12.04

 server 配置

  1,首先在進入找到/etc/apache2/apache2.conf的配置文件,里面有包含了較多配置文件的路徑如:httpd.conf/ports.conf(端口配置)/site-enabled/等

 2,在port.conf 配置端口(http port=80, https port = 443)

   NameVirtualHost *:80

   Listen 80

      NameVirtualHost *:443

   Listen 443

   3,找到證書以key的配置路徑在/etc/apache2/sites-enabled/default-ssl ,配置以下三處

  SSLCertificateFile            /etc/apache2/ssl/httpd.cert

  SSLCertificateKeyFile      /etc/apache2/ssl/httpd.key

      SSLCertificateChainFile   /etc/apache2/ssl/cacert.pem (這里cacert.pem和httpd.cert內容完全一樣) 

  生成證書時,配置common name = 本機IP,否則驗證時無法使用,命令如下:

  openssl req -x509 -nodes -newkey ras:2048 -keyout server.key -out server.crt -days 10950

    4,配置完成后,service apache2 restart

 

client使用

  wget -ca--certificate=/certPath/cert -P /dstFilePath https://...IP../srcFile;(若通過http訪問,client將不會驗證證書)

  wget --no-check-certificate  -P /dstFilePath http://...IP../srcFile;

  在client 使用證書時,本機時間一定要比server生成的時間晚。否則會提示證書 not alive.

 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM