Git Product home page Git Product logo

Comments (3)

LvKang-insist avatar LvKang-insist commented on June 12, 2024 3

1,客户端发起 Https 请求,链接到服务器的 443 端口
2,服务器响应请求,将证书发送到客户端
3,客户端认证证书,并从证书中提取出 服务端公钥
4,客户端使用公钥加密一个随机秘钥,并传到服务器
5,服务器使用 私钥解密出随机秘钥
6,通信双方使用随机秘钥为对称秘钥进行加密解密


加密的方式有:1,对称加密,2,非对称加密,3,证书加密

// 如果有问题还请指出

from android-daily-interview.

chipssss avatar chipssss commented on June 12, 2024 3

主要分为三部分,协商采用的对称加密算法,非对称加密传输pre-master,对称加密传输。

  1. client hello, server hello中协商加密算法,交换随机数 client random和server random,生成对称密钥用到;
  2. server端回证书给client,client验证证书并取出公钥匙,client端生成随机数pre-master采用公钥加密后传给server端,此时采用非对称加密
  3. 两方根据client random+server random+pre-master生成对称加密密钥,验证无误之后都采用对称加密传输。

扩展:

  1. 对称加密速度快,但密钥易被窃取;非对称加密速度慢,安全性高,通常采用RSA算法,证书的作用是为了保证传输的公钥不被第三方窃取。
  2. 为什么要使用client random和server random,直接采用pre-master不可以吗?
    目的是为了避免重放攻击,如果客户端也给证书给服务端验证的话可以不用两个随机数,但这样代价高,需要client本机安装证书。
    重放攻击的意思是(个人理解):中间者窃取客户端建立连接整个过程的发送报文,直接与server端建立连接,如client请求1个widget,但中间者把这个过程重复了10遍,这时返回给client端就是11个widget。当有两个随机数时,对于server,每个连接的server random都是不同的,因此它与中间者发送同样的报文建立连接时,由于server random的不同,后面对称加密的密钥也会不同,server可以拒绝掉中间者的请求。

// 以上有错误还请批正

from android-daily-interview.

yif-hong avatar yif-hong commented on June 12, 2024

https

from android-daily-interview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.