current position:Home>SSL/TLS protocol operating mechanism in https protocol
SSL/TLS protocol operating mechanism in https protocol
2022-08-06 18:33:49【why why】
https 协议相对于http 具有更高的安全性,Configuration when you need to specify the domain name SSL 证书,When shaking hands additional useTLS ,Briefly described in this paper, the two.
https
- HTTPS(全称:Hyper Text Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版.即HTTP下加入SSL层,HTTPS的安全基础是SSL(Secure Socket Layer).
- HTTPS 在 TCP 和 HTTP 之间增加了 TLS(Transport Layer Security,传输层安全),提供了内容加密、身份认证和数据完整性三大功能.
提供服务
- 认证用户和服务器,确保数据发送到正确的客户机和服务器
- 加密数据以防止数据中途被窃取
- 维护数据的完整性,确保数据在传输过程中不被改变
SSL/TLS 的作用
不使用SSL/TLS的HTTP通信,就是不加密的通信.所有信息明文传播,带来了三大风险.
(1) 窃听风险(eavesdropping):第三方可以获知通信内容.
(2) 篡改风险(tampering):第三方可以修改通信内容.
(3) 冒充风险(pretending):第三方可以冒充他人身份参与通信.
SSL/TLS协议是为了解决这三大风险而设计的,希望达到:
(1) 所有信息都是加密传播,第三方无法窃听.
(2) 具有校验机制,一旦被篡改,通信双方会立刻发现.
(3) 配备身份证书,防止身份被冒充.
互联网是开放环境,通信双方都是未知身份,这为协议的设计带来了很大的难度.而且,协议还必须能够经受所有匪夷所思的攻击,这使得SSL/TLS协议变得异常复杂.
SSL/TLS 历史
互联网加密通信协议的历史,几乎与互联网一样长.
1994年,NetScape公司设计了SSL协议(Secure Sockets Layer)的1.0版,但是未发布. 1995年,NetScape公司发布SSL 2.0版,很快发现有严重漏洞. 1996年,SSL 3.0版问世,得到大规模应用. 1999年,互联网标准化组织ISOC接替NetScape公司,发布了SSL的升级版TLS 1.0版. 2006年和2008年,TLS进行了两次升级,分别为TLS 1.1版和TLS 1.2版.最新的变动是2011年TLS 1.2的修订版.
目前,应用最广泛的是TLS 1.0,接下来是SSL 3.0.但是,主流浏览器都已经实现了TLS 1.2的支持.
TLS 1.0通常被标示为SSL 3.1,TLS 1.1为SSL 3.2,TLS 1.2为SSL 3.3.
SSL/TLS 基本的运行过程
SSL/TLS协议的基本思路是采用公钥加密法,也就是说,客户端先向服务器端索要公钥,然后用公钥加密信息,服务器收到密文后,用自己的私钥解密.
但是,这里有两个问题.
如何保证公钥不被篡改?
解决方法:将公钥放在数字证书中.只要证书是可信的,公钥就是可信的.
公钥加密计算量太大,如何减少耗用的时间?
解决方法:每一次对话(session),客户端和服务器端都生成一个"对话密钥"(session key),用它来加密信息.由于"对话密钥"是对称加密,所以运算速度非常快,而服务器公钥只用于加密"对话密钥"本身,这样就减少了加密运算的消耗时间.
因此,SSL/TLS协议的基本过程是这样的:
(1) 客户端向服务器端索要并验证公钥.
(2) 双方协商生成"对话密钥".
(3) 双方采用"对话密钥"进行加密通信.
上面过程的前两步,又称为"握手阶段"(handshake).
TLS 握手阶段的详细过程
"握手阶段"涉及四次通信,我们一个个来看.需要注意的是,"握手阶段"的所有通信都是明文的.
客户端发出请求(ClientHello)
首先,客户端(通常是浏览器)先向服务器发出加密通信的请求,这被叫做ClientHello请求.
在这一步,客户端主要向服务器提供以下信息.
(1) 支持的协议版本,比如TLS 1.0版.
(2) 一个客户端生成的随机数,稍后用于生成"对话密钥".
(3) 支持的加密方法,比如RSA公钥加密.
(4) 支持的压缩方法.
这里需要注意的是,客户端发送的信息之中不包括服务器的域名.也就是说,理论上服务器只能包含一个网站,否则会分不清应该向客户端提供哪一个网站的数字证书.这就是为什么通常一台服务器只能有一张数字证书的原因.
对于虚拟主机的用户来说,这当然很不方便.2006年,TLS协议加入了一个Server Name Indication扩展,允许客户端向服务器提供它所请求的域名.
服务器回应(SeverHello)
服务器收到客户端请求后,向客户端发出回应,这叫做SeverHello.服务器的回应包含以下内容.
(1) 确认使用的加密通信协议版本,比如TLS 1.0版本.如果浏览器与服务器支持的版本不一致,服务器关闭加密通信.
(2) 一个服务器生成的随机数,稍后用于生成"对话密钥".
(3) 确认使用的加密方法,比如RSA公钥加密.
(4) 服务器证书.
除了上面这些信息,如果服务器需要确认客户端的身份,就会再包含一项请求,要求客户端提供"客户端证书". 比如,金融机构往往只允许认证客户连入自己的网络,就会向正式客户提供USB密钥,里面就包含了一张客户端证书.
客户端回应
客户端收到服务器回应以后,首先验证服务器证书.如果证书不是可信机构颁布、或者证书中的域名与实际域名不一致、或者证书已经过期,就会向访问者显示一个警告,由其选择是否还要继续通信.
如果证书没有问题,客户端就会从证书中取出服务器的公钥.然后,向服务器发送下面三项信息.
(1) 一个随机数.该随机数用服务器公钥加密,防止被窃听.
(2) 编码改变通知,表示随后的信息都将用双方商定的加密方法和密钥发送.
(3) 客户端握手结束通知,表示客户端的握手阶段已经结束.这一项同时也是前面发送的所有内容的hash值,用来供服务器校验.
上面第一项的随机数,是整个握手阶段出现的第三个随机数,又称"pre-master key".有了它以后,客户端和服务器就同时有了三个随机数,接着双方就用事先商定的加密方法,各自生成本次会话所用的同一把"会话密钥".
至于为什么一定要用三个随机数,来生成"会话密钥",dog250解释得很好:
"不管是客户端还是服务器,都需要随机数,这样生成的密钥才不会每次都一样.由于SSL协议中证书是静态的,因此十分有必要引入一种随机因素来保证协商出来的密钥的随机性. 对于RSA密钥交换算法来说,pre-master-key本身就是一个随机数,再加上hello消息中的随机,三个随机数通过一个密钥导出器最终导出一个对称密钥. pre master的存在在于SSL协议不信任每个主机都能产生完全随机的随机数,如果随机数不随机,那么pre master secret就有可能被猜出来,那么仅使用pre master secret作为密钥就不合适了,因此必须引入新的随机因素,那么客户端和服务器加上pre master secret三个随机数一同生成的密钥就不容易被猜出了,一个伪随机可能完全不随机,可是是三个伪随机就十分接近随机了,每增加一个自由度,随机性增加的可不是一."
此外,If the previous step server requires a client certificate,客户端会在这一步发送证书及相关信息.
服务器的最后回应
服务器收到客户端的第三个随机数之后,计算生成本次会话所用的"会话密钥".然后,向客户端最后发送下面信息.
(1)编码改变通知,表示随后的信息都将用双方商定的加密方法和密钥发送. (2)服务器握手结束通知,表示服务器的握手阶段已经结束.这一项同时也是前面发送的所有内容的hash值,用来供客户端校验.
至此,整个握手阶段全部结束.接下来,客户端与服务器进入加密通信,就完全是使用普通的HTTP协议,只不过用"会话密钥"加密内容.
参考资料
copyright notice
author[why why],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/218/202208061814417936.html
The sidebar is recommended
- How to use wireless serial communication module to realize long-distance communication between touch screen and PLC?
- Getting Started with Vue2 - Rookie Level 1
- HTTP and HTTPS protocols
- 2022 Autumn Recruitment Front-end Interview Questions (1) (with answers)
- From function computing to serverless architecture
- Before 2022 the autumn recruit face questions (with answers) (2)
- About git's fatal: unable to access 'https://gitee.com/': Could not resolve host: gitee.com; Unknown error
- The sinkhole of Nginx's current limit!!
- Write a progress bar in JavaScript
- Write input box validation in JavaScript
guess what you like
CSS knowledge points
Write a random color in JavaScript
Construct HTTP
Webstorm opens and browses md files with garbled characters?
PHP+HTML+MySQL realizes login error
The comments in the Dygraphs Annotations
[React] Part VI Life Cycle
[React] Part VII Dom's diffing algorithm
To React the React in the setState after data didn't change
[React] The problem of React project startup stuck in Starting the development server...
Random recommended
- [React] The eighth part of react scaffolding installation and react scaffolding configuration agent
- [React] Part 5 Higher-Order Functions and Currying of Functions
- form and CSS
- In the Vue named Vue 】 【 encountered when component name "index" should always be multi - solution of word
- A pit in Nginx forwarding, operation and maintenance actually let me take the blame
- Easily converts HTML to PDF BFO Publisher
- vue2 typescript style type error?
- The back-end json is transferred to the front-end, but the front-end does not display?
- The sinkhole of Nginx current limit
- nginx service upgrade
- Vue gets the width and height attributes of the file file
- html submit form does not jump to the page
- CSS Tricks You Need to Know: Images
- Huawei FreeBuds Pro 2 review: the strongest TWS is here, this is the ceiling of wireless headphones
- Docker deploys a single page application
- Nginx and CDN
- vue click.stop stops the click event from continuing to propagate (stops the event from bubbling up)
- js array to remove the specified element [function encapsulation] (including object array to remove the specified element)
- CSS Drawing [Summary]
- [Webpack Quick Start] How to manually configure a webpack packaging tool for the project?
- The React components used in Spring MVC project
- Two Set collections get the same elements
- Samsung's Vietnam factory is operating at less than half, regretting closing production lines in China
- Send data to the front end with nodejs
- The implementation of the dotted line of the HTML+CSS common skills that the front end must know
- Front end will be commonly used HTML + CSS skills of mobile terminal 1 px borders
- Dedecms dream weaving template front-end list page data duplication solution
- vue-quill-editor rich text editor will clear spaces for content, filter empty strings, spaces; solution
- How to turn on the wireless screen mirroring function in win7
- Operation and maintenance practice - the latest Nginx binary build and compile lua-nginx-module dynamic link Lua script access Redis database read static resources implicit display
- Win7 wireless network list does not show up Win7 network connection icon disappears what to do
- Win7 and win10 which takes up less resources Win7 and win10 take up resources in detail
- JavaScript Knowledge Point Review--(2) Advanced Functions
- Openresty+nginx image server configuration, add http_image_filter_module module
- Docker quickly builds a PHP+Nginx+Mysql environment and steps on the pit diary
- Vue entry page for the first time, how to distinguish between created and activated?
- [Help] In the vue2 that the vue3 project is connected to as a subsystem, the whole project using el-drawer reports an error?
- Sketch91: How to set an aligned reference object and align it according to the specified element tutorial
- Study together to build the react + webpack + ts framework!!!!!!(a)
- Java Data Structures and Algorithms Lesson 9 - Sorting