HTTP中没有加密机制,主要是由于TCP/IP协议的工作机制。故进行加密。方式分为下面几类:
通信加密:
通过SSL(安全套接层)或TLS(安全传输层协议)的组合使用,加密HTTP的通信内容。与SSL组合使用的HTTP被称为HTTPS。它是对整个通信线路进行的加密处理。
内容加密:
对HTTP报文包含的内容进行加密处理。但是需要客户端和服务器端同时具备加密和解密机制。
HTTP+加密+认证+完整性保护=HTTP
HTTP是身披SSL外壳的HTTP,并非是新协议,只是通信接口部分用SSL和TLS协议代替。通常HTTP直接和TCP通信。
HTTP和HTTPS的优缺点:
HTTPS优点:
通信使用明文不加密,内容可能被窃听,也就是被抓包分析。
不验证通信方身份,可能遭到伪装。
无法验证报文的完整性,可能被篡改。
HTTPS缺点:
通信慢,大量消耗CPU和内存,在进行加密处理时,加密解密的运算处理会消耗硬件资源,导致负载增强。如果是非敏感信息则使用HTTP通信,只有包含个人信息等敏感数据时,才利用HTTPS加密通信。