HTTPS(全 稱:Hypertext Transfer Protocol over Secure Socket Layer),是以安全爲目標的HTTP通道,簡單講是HTTP的安全版。即HTTP下加入SSL層,HTTPS的安全基礎是SSL,因此加密的詳細內容 就需要SSL。 它是一個URI scheme(抽象標識符體系),句法類同http:體系。用於安全的HTTP數據傳輸。https:URL表明它使用了HTTP,但HTTPS存在不同 於HTTP的默認端口及一個加密/身份驗證層(在HTTP與TCP之間)。這個系統的最初研發由網景公司進行,提供了身份驗證與加密通訊方法,現在它被廣 泛用於萬維網上安全敏感的通訊,例如交易支付方面。
簡介
它是由Netscape開發並內置於其瀏覽器 中,用於對數據進行壓縮和解壓操作,並返回網絡上傳送回的結果。HTTPS實際上應用了 Netscape的安全套接字層(SSL)作爲HTTP應用層的子層。(HTTPS使用端口443,而不是像HTTP那樣使用端口80來和TCP/IP進 行通信。)SSL使用40 位關鍵字作爲RC4流加密算法,這對於商業信息的加密是合適的。HTTPS和SSL支持使用X.509數字認證,如果需要的話用戶可以確認發送者是誰。
也就是說它的主要作用可以分爲兩種:一種是建立一個信息安全通道,來保證數據傳輸的安全;另一種就是確認網站的真實性。Centos 6.2下配置https服務器的步驟,需要的朋友可以參考下。
HTTPS和HTTP的區別
一、https協議需要到ca申請證書,一般免費證書很少,需要交費。
二、http是超文本傳輸協議,信息是明文傳輸,https 則是具有安全性的ssl加密傳輸協議。
三、http和https使用的是完全不同的連接方式,用的端口也不一樣,前者是80,後者是443。
四、http的連接很簡單,是無狀態的;HTTPS協議是由SSL+HTTP協議構建的可進行加密傳輸、身份認證的網絡協議,比http協議安全。HTTPS解決的問題
一、信任主機的問題.
採 用https的服務器必須從CA (Certificate Authority)申請一個用於證明服務器用途類型的證書。該證書只有用於對應的服務器的時候,客戶端纔信任此主機。所以目前所有的銀行系統網站,關鍵 部分應用都是https 的。客戶通過信任該證書,從而信任了該主機。其實這樣做效率很低,但是銀行更側重安全。這一點對我們沒有任何異議,我們的服務器,採用的證書不管是自己發 布的還是從公衆的地方發佈的,其客戶端都是自己人,所以我們也就肯定信任該服務器。
二、通訊過程中的數據的泄密和被篡改
1. 一般意義上的https,就是服務器有一個證書。
a) 主要目的是保證服務器就是他聲稱的服務器,這個跟第一點一樣。
b) 服務端和客戶端之間的所有通訊,都是加密的。
i. 具體講,是客戶端產生一個對稱的密鑰,通過服務器的證書來交換密鑰,即一般意義上的握手過程。
ii. 接下來所有的信息往來就都是加密的。第三方即使截獲,也沒有任何意義,因爲他沒有密鑰,當然篡改也就沒有什麼意義了。
2. 少許對客戶端有要求的情況下,會要求客戶端也必須有一個證書。
a) 這裏客戶端證書,其實就類似表示個人信息的時候,除了用戶名/密碼,還有一個CA 認證過的身份。因爲個人證書一般來說是別人無法模擬的,所有這樣能夠更深的確認自己的身份。
b) 目前少數個人銀行的專業版是這種做法,具體證書可能是拿U盤(即U盾)作爲一個備份的載體
如果關注俺比較多,你肯定會比較眼熟,這上面的介紹來自RPM版安裝。同樣你可以借鑑(CentOS 6.2下配置https並實現SSL虛擬主機)
注:這裏使用的編譯參數是用於LDAP的架構服務,如果你單純的只需要SSL服務,或者web架構的話,一定要刪減相應參數
安裝Openssl
[root@chenyi ldmp]# tar zxf openssl-1.0.0e.tar.gz [root@chenyi ldmp]# cd openssl-1.0.0e [root@chenyi openssl-1.0.0e]# ./config --prefix=/software/ssl --openssldir=/software/openssl shared [root@chenyi openssl-1.0.0e]# make && make test &&make install
安裝apr
[root@chenyi ldmp]# tar zxf apr-1.4.5.tar.gz [root@chenyi ldmp]# cd apr-1.4.5 [root@chenyi apr-1.4.5]# ./configure --prefix=/software/apr [root@chenyi apr-1.4.5]# make && make install
安裝apr-util
[root@chenyi apr-util-1.3.12]# tar zxf apr-util-1.3.12.tar.gz [root@chenyi apr-util-1.3.12]# cd apr-util-1.3.12 [root@chenyi apr-util-1.3.12]# ./configure --prefix=/software/apr-util --with-apr=/software/apr/ --with-ldap-include=/software/openldap/include/ --with-ldap-lib=/software/openldap/lib/ --with-berkeley-db=/software/BerkeleyDB.5.2/ [root@chenyi apr-util-1.3.12]# make && make install
安裝apache
[root@chenyi httpd-2.2.21]# tar zxf httpd-2.2.21.tar.gz [root@chenyi httpd-2.2.21]# cd httpd-2.2.21 [root@chenyi httpd-2.2.21]# ./configure --prefix=/software/apache2 --sysconfdir=/etc/httpd --enable-ssl --with-ssl=/software/openssl/ --with-z=/software/zlib/ --enable-rewrite=shared --enable-static-support --enable-deflate=shared --enable-so --enable-dav --enable-dav-fs --enable-ldap --enable-authnz-ldap --with-included-apr --with-ldap --with-ldap-include=/software/openldap/include/ --with-ldap-lib=/software/openldap/lib --with-apr=/software/apr/bin/apr-1-config --with-apr-util=/software/apr-util/bin/apu-1-config [root@chenyi httpd-2.2.21]# make && make install
配置支持SSL
[root@chenyi httpd-2.2.21]# cd /etc/httpd/ [root@chenyi httpd]# mkdir ssl ssl.key ssl.crt [root@chenyi httpd]# openssl req -new -out server.csr [root@chenyi httpd]# openssl genrsa -out www.itchenyi.com.key 1024 Generating RSA private key, 1024 bit long modulus ........++++++ ............................++++++ e is 65537 (0x10001)
[root@chenyi httpd]# openssl req -new -key www.itchenyi.com.key -out www.itchenyi.com.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:shanghai Locality Name (eg, city) [Default City]:pudong Organization Name (eg, company) [Default Company Ltd]:chenyi Organizational Unit Name (eg, section) []:www Common Name (eg, your name or your server's hostname) []:www.itchenyi.com Email Address []:[email protected] Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:
[root@chenyi httpd]# openssl x509 -req -days 365 -in www.itchenyi.com.csr -signkey www.itchenyi.com.key -out www.itchenyi.com.crt Signature ok subject=/C=CN/ST=shanghai/L=pudong/O=chenyi/OU=ww/CN=www.itchenyi.com/[email protected] Getting Private key
查看相關配置(這裏也是需要你修改的地方)
[root@chenyi extra]# cat httpd-ssl.conf | grep SSLCertificateFile # Point SSLCertificateFile at a PEM encoded certificate. If SSLCertificateFile "/etc/httpd/www.itchenyi.com.crt" #SSLCertificateFile "/etc/httpd/server-dsa.crt" # the referenced file can be the same as SSLCertificateFile [root@chenyi extra]# cat httpd-ssl.conf | grep SSLCertificateFile # Point SSLCertificateFile at a PEM encoded certificate. If SSLCertificateFile "/etc/httpd/www.itchenyi.com.crt" #SSLCertificateFile "/etc/httpd/server-dsa.crt" # the referenced file can be the same as SSLCertificateFile
修改http-ssl.conf 注:[Directory如果設置不當,那麼是不能訪問的]
DocumentRoot "/home/wwwroot " <Directory /home/wwwroot> Order deny,allow Allow from all </Directory> ServerName www.itchenyi.com:443 ServerAdmin [email protected] ErrorLog "/software/apache2/logs/error_log" TransferLog "/software/apache2/logs/access_log"
修改/etc/httpd/httpd.conf 取消註釋 大約408行
Include /etc/httpd/extra/httpd-ssl.conf
重啓http服務 通過netstat查看如下:
[root@chenyi extra]# netstat -pant | grep httpd tcp 0 0 :::80 :::* LISTEN 6124/httpd tcp 0 0 :::443 :::* LISTEN 6124/httpd