Update HTTP.md

重新绘制配图,补充 TLS 握手、HTTP/3、WebSocket、跨域、单点登录与 OAuth 2.0、强缓存与协商缓存和常见状态码,更新内容编码等描述。
This commit is contained in:
CyC2018
2026-10-26 22:03:44 +08:00
parent d61e356e26
commit 0561863ad8
29 changed files with 1138 additions and 33 deletions
+58
View File
@@ -0,0 +1,58 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="300" viewBox="0 0 760 300">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="380" y="28" class="title">证书链:www.baidu.com 的证书如何被信任</text>
<rect x="30" y="60" width="220" height="110" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="140" y="82" class="c sub b" style="fill:#444">服务器证书</text>
<text x="140" y="104" class="c sub mono" style="fill:#444">baidu.com</text>
<text x="140" y="130" class="c sub">公钥:RSA 2048 位</text>
<text x="140" y="148" class="c sub">有效期 2026-07-09 ~ 2027-01-24</text>
<line x1="278" y1="115" x2="254" y2="115" class="arrow "/>
<text x="266" y="196" class="c sub"></text>
<rect x="280" y="60" width="220" height="110" rx="6" fill="#EAE9E7" stroke="#BFBEBA"/>
<text x="390" y="82" class="c sub b" style="fill:#444">中间证书</text>
<text x="390" y="104" class="c sub mono" style="fill:#444">GlobalSign RSA OV SSL CA 2018</text>
<text x="390" y="130" class="c sub">由根证书签名</text>
<text x="390" y="148" class="c sub">随服务器证书一起发送</text>
<line x1="528" y1="115" x2="504" y2="115" class="arrow "/>
<text x="516" y="196" class="c sub"></text>
<rect x="530" y="60" width="220" height="110" rx="6" fill="#C6ECE9" stroke="#7DBCB7"/>
<text x="640" y="82" class="c sub b" style="fill:#444">根证书</text>
<text x="640" y="104" class="c sub mono" style="fill:#444">GlobalSign Root R3</text>
<text x="640" y="130" class="c sub">自签名</text>
<text x="640" y="148" class="c sub">预装在操作系统的信任列表中</text>
<text x="255" y="196" class="c sub" style="fill:#766AA8">用中间证书的公钥验证服务器证书的签名</text>
<text x="505" y="196" class="c sub" style="fill:#766AA8">用根证书的公钥验证中间证书</text>
<text x="30" y="236" class="sub">浏览器还要检查:访问的域名 www.baidu.com 与证书中的域名匹配(Subject Alternative Name 中有 *.baidu.com),</text>
<text x="30" y="254" class="sub">证书在有效期内且没有被吊销。任何一步失败都会提示“连接不是私密连接”。</text>
<text x="30" y="278" class="sub">证书和签名是公开的,伪造者拿不到 CA 的私钥,就无法为自己的公钥生成有效签名。</text>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

+59
View File
@@ -0,0 +1,59 @@
<svg xmlns="http://www.w3.org/2000/svg" width="720" height="250" viewBox="0 0 720 250">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="360" y="28" class="title">非对称加密:公钥加密、私钥解密;私钥签名、公钥验证</text>
<text x="30" y="66" class="b">加密</text>
<rect x="90" y="50" width="110" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="145" y="69" class="c sub" style="fill:#444">会话密钥</text>
<line x1="202" y1="65" x2="286" y2="65" class="arrow "/>
<text x="244" y="57" class="c sub" style="fill:#207773">服务器公钥</text>
<rect x="290" y="50" width="150" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="365" y="69" class="c sub" style="fill:#444">密文 256 字节</text>
<line x1="442" y1="65" x2="526" y2="65" class="arrow "/>
<text x="484" y="57" class="c sub" style="fill:#766AA8">服务器私钥</text>
<rect x="530" y="50" width="110" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="585" y="69" class="c sub" style="fill:#444">会话密钥</text>
<text x="90" y="100" class="sub">任何人都能用公钥加密,只有持有私钥的服务器能解开</text>
<text x="30" y="156" class="b">签名</text>
<rect x="90" y="140" width="110" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="145" y="159" class="c sub" style="fill:#444">证书内容</text>
<line x1="202" y1="155" x2="286" y2="155" class="arrow "/>
<text x="244" y="147" class="c sub" style="fill:#766AA8">CA 私钥签名</text>
<rect x="290" y="140" width="150" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="365" y="159" class="c sub" style="fill:#444">签名</text>
<line x1="442" y1="155" x2="526" y2="155" class="arrow "/>
<text x="484" y="147" class="c sub" style="fill:#207773">CA 公钥验证</text>
<rect x="530" y="140" width="110" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="585" y="159" class="c sub" style="fill:#444">签名有效</text>
<text x="90" y="190" class="sub">只有 CA 能生成签名,任何人都能用 CA 的公钥检查,内容改动一个字节签名就对不上</text>
<text x="30" y="236" class="sub">2048 位 RSA 的密文和签名都是 256 字节。非对称运算比对称加密慢得多,所以只用在握手阶段。</text>
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

+50
View File
@@ -0,0 +1,50 @@
<svg xmlns="http://www.w3.org/2000/svg" width="720" height="200" viewBox="0 0 720 200">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="360" y="28" class="title">对称加密:加密和解密用同一个密钥</text>
<rect x="30" y="80" width="120" height="36" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="90" y="102" class="c sub" style="fill:#444">转账 100 元</text>
<line x1="152" y1="98" x2="222" y2="98" class="arrow "/>
<text x="187" y="90" class="c sub">AES 加密</text>
<rect x="226" y="80" width="270" height="36" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="361" y="102" class="c sub mono" style="fill:#444">c0b9bea2112248bbc17e8d6a15e542de</text>
<line x1="498" y1="98" x2="568" y2="98" class="arrow "/>
<text x="533" y="90" class="c sub">AES 解密</text>
<rect x="572" y="80" width="120" height="36" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="632" y="102" class="c sub" style="fill:#444">转账 100 元</text>
<path d="M182,128 v-4 a5,5 0 0 1 10,0 v4" fill="none" stroke="#B8B0DE" stroke-width="1.8"/>
<rect x="179" y="128" width="16" height="12" rx="2" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1.2"/>
<path d="M528,128 v-4 a5,5 0 0 1 10,0 v4" fill="none" stroke="#B8B0DE" stroke-width="1.8"/>
<rect x="525" y="128" width="16" height="12" rx="2" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1.2"/>
<text x="360" y="150" class="c sub mono" style="fill:#766AA8">同一个密钥 K = 000102…0e0f(16 字节)</text>
<text x="30" y="186" class="sub">用 openssl 实际计算(AES-128-CBC):14 字节的明文补齐到 16 字节;没有 K 无法还原,但 K 本身怎样安全地交给对方是个问题。</text>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

+72
View File
@@ -0,0 +1,72 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="300" viewBox="0 0 760 300">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="380" y="28" class="title">HTTP/2 的二进制分帧:一次 GET 请求和响应</text>
<rect x="30" y="52" width="300" height="96" rx="5" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
<line x1="30" y1="66" x2="330" y2="66" stroke="#BBBBBB" stroke-width="1"/>
<circle cx="39" cy="59" r="2.2" fill="#BBBBBB"/>
<circle cx="47" cy="59" r="2.2" fill="#BBBBBB"/>
<circle cx="55" cy="59" r="2.2" fill="#BBBBBB"/>
<text x="39" y="82" class="sub mono">GET /index.html HTTP/1.1</text>
<text x="39" y="98" class="sub mono">Host: www.example.com</text>
<text x="39" y="114" class="sub mono">User-Agent: Mozilla/5.0 …</text>
<text x="39" y="130" class="sub mono">Accept: text/html</text>
<text x="180" y="168" class="c sub">HTTP/1.1:文本,150 字节</text>
<line x1="340" y1="100" x2="400" y2="100" class="arrow "/>
<text x="370" y="92" class="c sub">HTTP/2</text>
<rect x="400" y="60" width="70" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="435" y="79" class="c sub b" style="fill:#444">HEADERS</text>
<rect x="470" y="60" width="80" height="30" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="510" y="79" class="c sub mono" style="fill:#444">stream 1</text>
<rect x="550" y="60" width="120" height="30" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="610" y="79" class="c sub" style="fill:#444">78 字节</text>
<text x="680" y="80" class="sub">请求首部</text>
<rect x="400" y="130" width="70" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="435" y="149" class="c sub b" style="fill:#444">HEADERS</text>
<rect x="470" y="130" width="80" height="30" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="510" y="149" class="c sub mono" style="fill:#444">stream 1</text>
<rect x="550" y="130" width="120" height="30" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="610" y="149" class="c sub" style="fill:#444">… 字节</text>
<text x="680" y="150" class="sub">响应首部</text>
<rect x="400" y="170" width="70" height="30" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
<text x="435" y="189" class="c sub b" style="fill:#444">DATA</text>
<rect x="470" y="170" width="80" height="30" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="510" y="189" class="c sub mono" style="fill:#444">stream 1</text>
<rect x="550" y="170" width="120" height="30" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="610" y="189" class="c sub" style="fill:#444">577 字节</text>
<text x="680" y="190" class="sub">页面内容</text>
<text x="410" y="52" class="sub"></text>
<text x="400" y="122" class="sub b" style="fill:#444">服务器返回:</text>
<text x="30" y="230" class="sub">每个帧前面有 9 字节的帧头:长度、类型、标志和流 ID。请求和响应属于同一个流(stream 1),</text>
<text x="30" y="248" class="sub">所以多个请求可以在一个 TCP 连接上交错发送,接收方按流 ID 重新组装。</text>
<text x="30" y="274" class="sub">78 字节是用 hpack 库按图中首部实际编码的结果;577 字节是 www.example.com 首页的大小。</text>
</svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

+49
View File
@@ -0,0 +1,49 @@
<svg xmlns="http://www.w3.org/2000/svg" width="720" height="260" viewBox="0 0 720 260">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="360" y="28" class="title">服务端推送:请求页面时一起发送样式</text>
<rect x="80" y="46" width="140" height="32" rx="6" fill="#C6ECE9" stroke="#7DBCB7"/>
<text x="150" y="66.5" class="c sub b">浏览器</text>
<line x1="150" y1="80" x2="150" y2="230" stroke="#BBB" stroke-dasharray="4 4"/>
<rect x="500" y="46" width="140" height="32" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="570" y="66.5" class="c sub b">服务器</text>
<line x1="570" y1="80" x2="570" y2="230" stroke="#BBB" stroke-dasharray="4 4"/>
<line x1="150" y1="100" x2="570" y2="100" class="arrow "/>
<text x="360" y="94" class="c sub mono" style="fill:#444">stream 1:GET /page.html</text>
<line x1="570" y1="134" x2="150" y2="134" class="arrow dash"/>
<text x="360" y="128" class="c sub mono" style="fill:#444">stream 1:PUSH_PROMISE /style.css</text>
<line x1="570" y1="166" x2="150" y2="166" class="arrow dash"/>
<text x="360" y="160" class="c sub mono" style="fill:#444">stream 1:page.html 的内容</text>
<line x1="570" y1="198" x2="150" y2="198" class="arrow dash"/>
<text x="360" y="192" class="c sub mono" style="fill:#444">stream 2:style.css 的内容</text>
<text x="30" y="250" class="sub">服务器推送的流 ID 为偶数。浏览器解析到 style.css 时它已经在缓存里,省去一次请求的往返。</text>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

+60
View File
@@ -0,0 +1,60 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="230" viewBox="0 0 760 230">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="380" y="28" class="title">多路复用:三个请求共用一个 TCP 连接</text>
<rect x="40" y="70" width="680" height="64" rx="32" fill="#FFFFFF" stroke="#BBBBBB"/>
<rect x="80" y="86" width="60" height="32" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="110" y="106" class="c sub" style="fill:#444">HEADERS 1</text>
<rect x="150" y="86" width="60" height="32" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
<text x="180" y="106" class="c sub" style="fill:#444">HEADERS 3</text>
<rect x="220" y="86" width="60" height="32" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="250" y="106" class="c sub" style="fill:#444">DATA 1</text>
<rect x="290" y="86" width="60" height="32" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
<text x="320" y="106" class="c sub" style="fill:#444">HEADERS 5</text>
<rect x="360" y="86" width="60" height="32" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
<text x="390" y="106" class="c sub" style="fill:#444">DATA 3</text>
<rect x="430" y="86" width="60" height="32" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="460" y="106" class="c sub" style="fill:#444">DATA 1</text>
<rect x="500" y="86" width="60" height="32" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
<text x="530" y="106" class="c sub" style="fill:#444">DATA 5</text>
<rect x="570" y="86" width="60" height="32" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
<text x="600" y="106" class="c sub" style="fill:#444">DATA 3</text>
<rect x="640" y="86" width="60" height="32" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
<text x="670" y="106" class="c sub" style="fill:#444">DATA 5</text>
<line x1="700" y1="102" x2="728" y2="102" class="arrow "/>
<text x="40" y="60" class="sub b" style="fill:#444">一个 TCP 连接</text>
<text x="40" y="162" class="sub" style="fill:#296898">stream 1:/index.html</text>
<text x="260" y="162" class="sub" style="fill:#207773">stream 3:/style.css</text>
<text x="470" y="162" class="sub" style="fill:#766AA8">stream 5:/app.js</text>
<text x="40" y="196" class="sub">帧可以交错发送,一个响应慢不会挡住其它响应;但 TCP 丢包时所有流都要等重传,这是 HTTP/3 改用 QUIC 的原因。</text>
<text x="40" y="214" class="sub">客户端发起的流 ID 为奇数。</text>
</svg>

After

Width:  |  Height:  |  Size: 3.9 KiB

+93
View File
@@ -0,0 +1,93 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="330" viewBox="0 0 760 330">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="380" y="28" class="title">首部压缩:第二次请求只需 21 字节</text>
<rect x="30" y="50" width="120" height="24" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="90" y="66" class="c sub" style="fill:#444">首部</text>
<rect x="150" y="50" width="190" height="24" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="245" y="66" class="c sub" style="fill:#444">值</text>
<rect x="340" y="50" width="300" height="24" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="490" y="66" class="c sub" style="fill:#444">编码方式</text>
<rect x="640" y="50" width="80" height="24" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="680" y="66" class="c sub" style="fill:#444">字节数</text>
<rect x="30" y="74" width="120" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="90" y="92" class="c sub mono" style="fill:#444">:method</text>
<rect x="150" y="74" width="190" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="245" y="92" class="c sub mono" style="fill:#444">GET</text>
<rect x="340" y="74" width="300" height="28" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="490" y="92" class="c sub" style="fill:#444">静态表第 2 项</text>
<rect x="640" y="74" width="80" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="680" y="92" class="c sub mono" style="fill:#444">1</text>
<rect x="30" y="102" width="120" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="90" y="120" class="c sub mono" style="fill:#444">:scheme</text>
<rect x="150" y="102" width="190" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="245" y="120" class="c sub mono" style="fill:#444">https</text>
<rect x="340" y="102" width="300" height="28" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="490" y="120" class="c sub" style="fill:#444">静态表第 7 项</text>
<rect x="640" y="102" width="80" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="680" y="120" class="c sub mono" style="fill:#444">1</text>
<rect x="30" y="130" width="120" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="90" y="148" class="c sub mono" style="fill:#444">:authority</text>
<rect x="150" y="130" width="190" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="245" y="148" class="c sub mono" style="fill:#444">www.example.com</text>
<rect x="340" y="130" width="300" height="28" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
<text x="490" y="148" class="c sub" style="fill:#444">动态表(第一次请求时加入)</text>
<rect x="640" y="130" width="80" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="680" y="148" class="c sub mono" style="fill:#444">1</text>
<rect x="30" y="158" width="120" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="90" y="176" class="c sub mono" style="fill:#444">:path</text>
<rect x="150" y="158" width="190" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="245" y="176" class="c sub mono" style="fill:#444">/style.css</text>
<rect x="340" y="158" width="300" height="28" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
<text x="490" y="176" class="c sub" style="fill:#444">新值:名字用静态表,值用 Huffman 编码</text>
<rect x="640" y="158" width="80" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="680" y="176" class="c sub mono" style="fill:#444">9</text>
<rect x="30" y="186" width="120" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="90" y="204" class="c sub mono" style="fill:#444">user-agent</text>
<rect x="150" y="186" width="190" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="245" y="204" class="c sub" style="fill:#444">Mozilla/5.0 …(64 字节)</text>
<rect x="340" y="186" width="300" height="28" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
<text x="490" y="204" class="c sub" style="fill:#444">动态表(第一次请求时加入)</text>
<rect x="640" y="186" width="80" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="680" y="204" class="c sub mono" style="fill:#444">1</text>
<rect x="30" y="214" width="120" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="90" y="232" class="c sub mono" style="fill:#444">accept</text>
<rect x="150" y="214" width="190" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="245" y="232" class="c sub mono" style="fill:#444">text/css</text>
<rect x="340" y="214" width="300" height="28" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
<text x="490" y="232" class="c sub" style="fill:#444">新值:名字用静态表,值用 Huffman 编码</text>
<rect x="640" y="214" width="80" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
<text x="680" y="232" class="c sub mono" style="fill:#444">8</text>
<text x="30" y="272" class="sub">同样的请求用 HTTP/1.1 的文本格式是 148 字节;第一次请求要建立动态表,编码后 78 字节。</text>
<text x="30" y="290" class="sub">静态表是协议规定的 61 个常见首部;动态表由双方各自维护,保存本连接中出现过的首部,之后只发送序号。</text>
<text x="30" y="314" class="sub">以上字节数由 hpack 4.0 库编码得到(RFC 7541)。</text>
</svg>

After

Width:  |  Height:  |  Size: 7.1 KiB

+52
View File
@@ -0,0 +1,52 @@
<svg xmlns="http://www.w3.org/2000/svg" width="740" height="300" viewBox="0 0 740 300">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="370" y="28" class="title">CONNECT:通过代理建立隧道</text>
<rect x="50" y="46" width="140" height="32" rx="6" fill="#C6ECE9" stroke="#7DBCB7"/>
<text x="120" y="66.5" class="c sub b">浏览器</text>
<line x1="120" y1="80" x2="120" y2="270" stroke="#BBB" stroke-dasharray="4 4"/>
<rect x="300" y="46" width="140" height="32" rx="6" fill="#EAE9E7" stroke="#BFBEBA"/>
<text x="370" y="66.5" class="c sub b">代理 proxy:8080</text>
<line x1="370" y1="80" x2="370" y2="270" stroke="#BBB" stroke-dasharray="4 4"/>
<rect x="550" y="46" width="140" height="32" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="620" y="66.5" class="c sub b">www.example.com:443</text>
<line x1="620" y1="80" x2="620" y2="270" stroke="#BBB" stroke-dasharray="4 4"/>
<line x1="120" y1="110" x2="370" y2="110" class="arrow "/>
<text x="245" y="104" class="c sub mono" style="fill:#444">CONNECT www.example.com:443 HTTP/1.1</text>
<line x1="370" y1="140" x2="620" y2="140" class="arrow "/>
<text x="495" y="134" class="c sub" style="fill:#444">建立 TCP 连接</text>
<line x1="370" y1="170" x2="120" y2="170" class="arrow dash"/>
<text x="245" y="164" class="c sub mono" style="fill:#444">HTTP/1.1 200 Connection Established</text>
<rect x="120" y="196" width="500" height="34" rx="17" fill="#E6E3FA" fill-opacity="0.5" stroke="#B8B0DE"/>
<text x="370" y="218" class="c sub" style="fill:#444">TLS 握手和加密的 HTTP 报文,代理只转发字节,看不到内容</text>
<text x="30" y="290" class="sub">代理只知道目标主机和端口;之后它像一根管道,把两端的数据原样转发。</text>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

+74
View File
@@ -0,0 +1,74 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="330" viewBox="0 0 760 330">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="380" y="28" class="title">短连接、长连接与流水线:请求 3 个资源</text>
<text x="108" y="90" class="sub b e" style="fill:#444">短连接</text>
<rect x="122" y="70" width="86" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="165" y="90" class="c sub" style="fill:#444">握手</text>
<rect x="212" y="70" width="86" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="255" y="90" class="c sub" style="fill:#444">请求 1</text>
<rect x="302" y="70" width="86" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="345" y="90" class="c sub" style="fill:#444">握手</text>
<rect x="392" y="70" width="86" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="435" y="90" class="c sub" style="fill:#444">请求 2</text>
<rect x="482" y="70" width="86" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="525" y="90" class="c sub" style="fill:#444">握手</text>
<rect x="572" y="70" width="86" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="615" y="90" class="c sub" style="fill:#444">请求 3</text>
<text x="672" y="90" class="sub b" style="fill:#444">6 个 RTT</text>
<text x="108" y="156" class="sub b e" style="fill:#444">长连接</text>
<rect x="122" y="136" width="86" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="165" y="156" class="c sub" style="fill:#444">握手</text>
<rect x="212" y="136" width="86" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="255" y="156" class="c sub" style="fill:#444">请求 1</text>
<rect x="302" y="136" width="86" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="345" y="156" class="c sub" style="fill:#444">请求 2</text>
<rect x="392" y="136" width="86" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="435" y="156" class="c sub" style="fill:#444">请求 3</text>
<text x="672" y="156" class="sub b" style="fill:#444">4 个 RTT</text>
<text x="108" y="222" class="sub b e" style="fill:#444">流水线</text>
<rect x="122" y="202" width="86" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="165" y="222" class="c sub" style="fill:#444">握手</text>
<rect x="212" y="202" width="113" height="30" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
<text x="268.5" y="222" class="c sub" style="fill:#444">请求 1、2、3 连续发出</text>
<text x="672" y="222" class="sub b" style="fill:#444">约 2 个 RTT</text>
<text x="120" y="280" class="c sub mono">0</text>
<text x="210" y="280" class="c sub mono">1</text>
<text x="300" y="280" class="c sub mono">2</text>
<text x="390" y="280" class="c sub mono">3</text>
<text x="480" y="280" class="c sub mono">4</text>
<text x="570" y="280" class="c sub mono">5</text>
<text x="660" y="280" class="c sub mono">6</text>
<line x1="120" y1="268" x2="660" y2="268" class="line"/>
<text x="660" y="298" class="c sub">RTT</text>
<text x="30" y="316" class="sub">灰色是 TCP 三次握手,每段约 1 个 RTT。HTTP/1.1 默认使用长连接;流水线中响应仍需按顺序返回,前一个慢了会阻塞后面的。</text>
</svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

+109
View File
@@ -0,0 +1,109 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="260" viewBox="0 0 760 260">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="380" y="28" class="title">正向代理与反向代理</text>
<rect x="30" y="46" width="350" height="170" rx="8" class="frame"/>
<text x="40" y="64" class="b">正向代理</text>
<rect x="42" y="78" width="190" height="126" rx="8" fill="#C6ECE9" fill-opacity="0.25"/>
<text x="52" y="196" class="sub">内网</text>
<rect x="60" y="100" width="40" height="27.2" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<rect x="64" y="104" width="32" height="19.2" rx="1.5" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="0.8"/>
<path d="M76,127.2 v5 M84,127.2 v5" stroke="#7FB2D6" stroke-width="1.4"/>
<rect x="68" y="132.2" width="24" height="3.5" rx="1.5" fill="#7FB2D6"/>
<text x="80" y="150" class="c sub">客户端</text>
<rect x="160" y="98" width="40" height="13" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
<circle cx="167" cy="104.5" r="2" fill="#BFBEBA"/>
<line x1="174" y1="104.5" x2="193" y2="104.5" stroke="#BFBEBA" stroke-width="1"/>
<rect x="160" y="114" width="40" height="13" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
<circle cx="167" cy="120.5" r="2" fill="#BFBEBA"/>
<line x1="174" y1="120.5" x2="193" y2="120.5" stroke="#BFBEBA" stroke-width="1"/>
<rect x="160" y="130" width="40" height="13" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
<circle cx="167" cy="136.5" r="2" fill="#BFBEBA"/>
<line x1="174" y1="136.5" x2="193" y2="136.5" stroke="#BFBEBA" stroke-width="1"/>
<text x="180" y="150" class="c sub b">代理</text>
<rect x="300" y="98" width="40" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="307" cy="104.5" r="2" fill="#7FB2D6"/>
<line x1="314" y1="104.5" x2="333" y2="104.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="300" y="114" width="40" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="307" cy="120.5" r="2" fill="#7FB2D6"/>
<line x1="314" y1="120.5" x2="333" y2="120.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="300" y="130" width="40" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="307" cy="136.5" r="2" fill="#7FB2D6"/>
<line x1="314" y1="136.5" x2="333" y2="136.5" stroke="#7FB2D6" stroke-width="1"/>
<text x="320" y="150" class="c sub">网站</text>
<line x1="104" y1="116" x2="156" y2="116" class="arrow "/>
<line x1="204" y1="116" x2="296" y2="116" class="arrow "/>
<text x="250" y="108" class="c sub">互联网</text>
<text x="205" y="236" class="c sub">代理客户端:服务器看到的是代理的地址</text>
<rect x="410" y="46" width="350" height="170" rx="8" class="frame"/>
<text x="420" y="64" class="b">反向代理</text>
<rect x="550" y="78" width="198" height="126" rx="8" fill="#C6E4FB" fill-opacity="0.25"/>
<text x="710" y="196" class="sub">机房</text>
<rect x="440" y="100" width="40" height="27.2" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<rect x="444" y="104" width="32" height="19.2" rx="1.5" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="0.8"/>
<path d="M456,127.2 v5 M464,127.2 v5" stroke="#7FB2D6" stroke-width="1.4"/>
<rect x="448" y="132.2" width="24" height="3.5" rx="1.5" fill="#7FB2D6"/>
<text x="460" y="150" class="c sub">客户端</text>
<rect x="570" y="98" width="40" height="13" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
<circle cx="577" cy="104.5" r="2" fill="#BFBEBA"/>
<line x1="584" y1="104.5" x2="603" y2="104.5" stroke="#BFBEBA" stroke-width="1"/>
<rect x="570" y="114" width="40" height="13" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
<circle cx="577" cy="120.5" r="2" fill="#BFBEBA"/>
<line x1="584" y1="120.5" x2="603" y2="120.5" stroke="#BFBEBA" stroke-width="1"/>
<rect x="570" y="130" width="40" height="13" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
<circle cx="577" cy="136.5" r="2" fill="#BFBEBA"/>
<line x1="584" y1="136.5" x2="603" y2="136.5" stroke="#BFBEBA" stroke-width="1"/>
<text x="590" y="150" class="c sub b">Nginx</text>
<rect x="693" y="82" width="34" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="700" cy="88.5" r="2" fill="#7FB2D6"/>
<line x1="707" y1="88.5" x2="720" y2="88.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="693" y="98" width="34" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="700" cy="104.5" r="2" fill="#7FB2D6"/>
<line x1="707" y1="104.5" x2="720" y2="104.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="693" y="120" width="34" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="700" cy="126.5" r="2" fill="#7FB2D6"/>
<line x1="707" y1="126.5" x2="720" y2="126.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="693" y="136" width="34" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="700" cy="142.5" r="2" fill="#7FB2D6"/>
<line x1="707" y1="142.5" x2="720" y2="142.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="693" y="158" width="34" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="700" cy="164.5" r="2" fill="#7FB2D6"/>
<line x1="707" y1="164.5" x2="720" y2="164.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="693" y="174" width="34" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="700" cy="180.5" r="2" fill="#7FB2D6"/>
<line x1="707" y1="180.5" x2="720" y2="180.5" stroke="#7FB2D6" stroke-width="1"/>
<line x1="484" y1="116" x2="566" y2="116" class="arrow "/>
<line x1="614" y1="116" x2="690" y2="92" class="arrow "/>
<line x1="614" y1="116" x2="690" y2="130" class="arrow "/>
<line x1="614" y1="116" x2="690" y2="168" class="arrow "/>
<text x="585" y="236" class="c sub">代理服务器:客户端只知道代理的地址</text>
</svg>

After

Width:  |  Height:  |  Size: 7.3 KiB

+51
View File
@@ -0,0 +1,51 @@
<svg xmlns="http://www.w3.org/2000/svg" width="740" height="300" viewBox="0 0 740 300">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="370" y="28" class="title">混合加密:用非对称加密传递会话密钥(TLS 1.2 的 RSA 密钥交换)</text>
<rect x="80" y="46" width="140" height="32" rx="6" fill="#C6ECE9" stroke="#7DBCB7"/>
<text x="150" y="66.5" class="c sub b">浏览器</text>
<line x1="150" y1="80" x2="150" y2="270" stroke="#BBB" stroke-dasharray="4 4"/>
<rect x="520" y="46" width="140" height="32" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="590" y="66.5" class="c sub b">服务器(持有私钥)</text>
<line x1="590" y1="80" x2="590" y2="270" stroke="#BBB" stroke-dasharray="4 4"/>
<line x1="150" y1="110" x2="590" y2="110" class="arrow "/>
<text x="370" y="104" class="c sub" style="fill:#444">① 客户端随机数</text>
<line x1="590" y1="144" x2="150" y2="144" class="arrow dash"/>
<text x="370" y="138" class="c sub" style="fill:#444">② 服务器随机数 + 证书(含公钥)</text>
<line x1="150" y1="178" x2="590" y2="178" class="arrow "/>
<text x="370" y="172" class="c sub" style="fill:#444">③ 用公钥加密的预主密钥</text>
<text x="138" y="210" class="sub e" style="fill:#766AA8">三者算出会话密钥</text>
<text x="602" y="210" class="sub" style="fill:#766AA8">解密后算出同样的会话密钥</text>
<rect x="150" y="226" width="440" height="30" rx="15" fill="#E6E3FA" fill-opacity="0.5" stroke="#B8B0DE"/>
<text x="370" y="246" class="c sub" style="fill:#444">④ 之后的 HTTP 报文用会话密钥对称加密(例如 AES-GCM)</text>
<text x="30" y="290" class="sub">这种方式下私钥一旦泄露,之前录下的通信都能被解密,TLS 1.3 已经去掉它,改用 ECDHE 密钥交换。</text>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

+62
View File
@@ -0,0 +1,62 @@
<svg xmlns="http://www.w3.org/2000/svg" width="720" height="280" viewBox="0 0 720 280">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="360" y="28" class="title">HTTPS:HTTP 报文交给 TLS 加密后再交给 TCP</text>
<text x="120" y="56" class="c b">HTTP</text>
<rect x="60" y="66" width="120" height="32" rx="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="120" y="86" class="c sub b" style="fill:#444">HTTP</text>
<rect x="60" y="104" width="120" height="32" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="120" y="124" class="c sub b" style="fill:#444">TCP</text>
<rect x="60" y="142" width="120" height="32" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="120" y="162" class="c sub b" style="fill:#444">IP</text>
<text x="300" y="56" class="c b">HTTPS</text>
<rect x="240" y="66" width="120" height="32" rx="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="300" y="86" class="c sub b" style="fill:#444">HTTP</text>
<rect x="240" y="104" width="120" height="32" rx="4" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
<text x="300" y="124" class="c sub b" style="fill:#444">TLS</text>
<rect x="240" y="142" width="120" height="32" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="300" y="162" class="c sub b" style="fill:#444">TCP</text>
<rect x="240" y="180" width="120" height="32" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="300" y="200" class="c sub b" style="fill:#444">IP</text>
<text x="420" y="60" class="b">抓包能看到的内容</text>
<rect x="420" y="72" width="270" height="36" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="430" y="87" class="sub b" style="fill:#444">IP、TCP 首部</text>
<text x="430" y="102" class="sub">明文:双方的地址和端口</text>
<rect x="420" y="116" width="270" height="36" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="430" y="131" class="sub b" style="fill:#444">TLS 记录头</text>
<text x="430" y="146" class="sub">明文:类型、版本、长度</text>
<rect x="420" y="160" width="270" height="36" rx="4" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
<text x="430" y="175" class="sub b" style="fill:#444">HTTP 请求行、首部、主体</text>
<text x="430" y="190" class="sub">全部加密,包括 URL 和 Cookie</text>
<text x="30" y="240" class="sub">HTTPS 默认端口 443。握手时 ClientHello 中的 SNI(要访问的域名)仍是明文,</text>
<text x="30" y="258" class="sub">所以中间人能知道访问的是哪个网站,但看不到访问了哪个页面、提交了什么内容。</text>
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

+64
View File
@@ -0,0 +1,64 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="560" viewBox="0 0 760 560">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="380" y="28" class="title">OAuth 2.0 授权码流程:令牌由后端换取,不经过浏览器</text>
<rect x="10" y="52" width="200" height="32" rx="6" fill="#E6E3FA" stroke="#B8B0DE"/>
<text x="110" y="72.5" class="c sub b">用户的浏览器</text>
<line x1="110" y1="84" x2="110" y2="520" stroke="#C8C8C8" stroke-dasharray="4 3"/>
<rect x="280" y="52" width="200" height="32" rx="6" fill="#C6ECE9" stroke="#7DBCB7"/>
<text x="380" y="72.5" class="c sub b">笔记网站 notes.example.com</text>
<line x1="380" y1="84" x2="380" y2="520" stroke="#C8C8C8" stroke-dasharray="4 3"/>
<rect x="550" y="52" width="200" height="32" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="650" y="72.5" class="c sub b">授权服务器 id.example.com</text>
<line x1="650" y1="84" x2="650" y2="520" stroke="#C8C8C8" stroke-dasharray="4 3"/>
<line x1="114" y1="116" x2="374" y2="116" class="arrow "/>
<text x="245" y="109" class="c sub">① 点击“用账号中心登录”</text>
<line x1="376" y1="160" x2="116" y2="160" class="arrow "/>
<text x="245" y="153" class="c sub">② 302 到 id.example.com/authorize</text>
<text x="245" y="174" class="c sub">带上 state 和 code_challenge</text>
<line x1="114" y1="218" x2="644" y2="218" class="arrow "/>
<text x="128" y="211" class="sub">③ GET /authorize,用户登录并点击同意</text>
<line x1="646" y1="262" x2="116" y2="262" class="arrow "/>
<text x="128" y="255" class="sub">④ 302 到 notes.example.com/callback</text>
<text x="128" y="276" class="sub mono">?code=R9Ydi...&amp;state=x7Kp2</text>
<line x1="114" y1="320" x2="374" y2="320" class="arrow "/>
<text x="245" y="313" class="c sub">⑤ GET /callback?code=R9Ydi...&amp;state=x7Kp2</text>
<line x1="384" y1="364" x2="644" y2="364" class="arrow green"/>
<text x="515" y="357" class="c sub ok">⑥ POST /token:code + code_verifier</text>
<line x1="646" y1="408" x2="386" y2="408" class="arrow green"/>
<text x="515" y="401" class="c sub ok">⑦ {"access_token": "v-7Dl...", "expires_in": 3600}</text>
<line x1="384" y1="452" x2="644" y2="452" class="arrow green"/>
<text x="515" y="445" class="c sub ok">⑧ GET /userinfo,Authorization: Bearer v-7Dl...</text>
<line x1="376" y1="496" x2="116" y2="496" class="arrow "/>
<text x="245" y="489" class="c sub">⑨ 登录成功,Set-Cookie: 笔记网站自己的会话</text>
<text x="24" y="540" class="sub">绿色是笔记网站后端与授权服务器之间的直接请求,访问令牌不经过浏览器;授权码经过浏览器,但只能用一次,换令牌时还要提供 code_verifier。</text>
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

+82
View File
@@ -0,0 +1,82 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="470" viewBox="0 0 760 470">
<style>
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
.b { font-weight: bold; }
.c { text-anchor: middle; }
.e { text-anchor: end; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.mono { font-family: Menlo, Consolas, monospace; }
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
.red { stroke: #C0605A; marker-end: url(#r); }
.green { stroke: #6A9F68; marker-end: url(#g); }
.dash { stroke-dasharray: 5 4; }
.line { stroke: #555; stroke-width: 1.1; fill: none; }
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
.shadow { fill: #DADADA; }
</style>
<defs>
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
</marker>
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
</marker>
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
</marker>
</defs>
<rect width="100%" height="100%" fill="#FFFFFF"/>
<text x="380" y="28" class="title">TLS 1.2 与 TLS 1.3 的握手(本机 openssl 实测的报文顺序)</text>
<text x="200" y="58" class="c b">TLS 1.2:www.baidu.com</text>
<line x1="70" y1="70" x2="70" y2="420" stroke="#BBB" stroke-dasharray="4 4"/>
<line x1="330" y1="70" x2="330" y2="420" stroke="#BBB" stroke-dasharray="4 4"/>
<text x="70" y="432" class="c sub">客户端</text>
<text x="330" y="432" class="c sub">服务器</text>
<line x1="70" y1="86" x2="330" y2="86" class="arrow "/>
<text x="200" y="81" class="c sub mono" style="fill:#444">ClientHello</text>
<line x1="330" y1="128" x2="70" y2="128" class="arrow dash"/>
<text x="200" y="123" class="c sub mono" style="fill:#444">ServerHello</text>
<line x1="330" y1="160" x2="70" y2="160" class="arrow dash"/>
<text x="200" y="155" class="c sub mono" style="fill:#444">Certificate</text>
<line x1="330" y1="192" x2="70" y2="192" class="arrow dash"/>
<text x="200" y="187" class="c sub mono" style="fill:#444">ServerKeyExchange</text>
<text x="200" y="204" class="c sub">ECDHE 公钥 + 签名</text>
<line x1="330" y1="236" x2="70" y2="236" class="arrow dash"/>
<text x="200" y="231" class="c sub mono" style="fill:#444">ServerHelloDone</text>
<line x1="70" y1="278" x2="330" y2="278" class="arrow "/>
<text x="200" y="273" class="c sub mono" style="fill:#444">ClientKeyExchange</text>
<text x="200" y="290" class="c sub">ECDHE 公钥</text>
<line x1="70" y1="322" x2="330" y2="322" class="arrow "/>
<text x="200" y="317" class="c sub mono" style="fill:#444">ChangeCipherSpec, Finished</text>
<line x1="330" y1="364" x2="70" y2="364" class="arrow dash"/>
<text x="200" y="359" class="c sub mono" style="fill:#444">ChangeCipherSpec, Finished</text>
<line x1="70" y1="406" x2="330" y2="406" class="arrow green"/>
<text x="200" y="401" class="c sub mono" style="fill:#444">HTTP 请求(加密)</text>
<text x="200" y="452" class="c sub b" style="fill:#296898">2 个 RTT 后才能发送请求</text>
<text x="570" y="58" class="c b">TLS 1.3:www.example.com</text>
<line x1="440" y1="70" x2="440" y2="420" stroke="#BBB" stroke-dasharray="4 4"/>
<line x1="700" y1="70" x2="700" y2="420" stroke="#BBB" stroke-dasharray="4 4"/>
<text x="440" y="432" class="c sub">客户端</text>
<text x="700" y="432" class="c sub">服务器</text>
<line x1="440" y1="86" x2="700" y2="86" class="arrow "/>
<text x="570" y="81" class="c sub mono" style="fill:#444">ClientHello + key_share</text>
<text x="570" y="98" class="c sub">带上 ECDHE 公钥</text>
<line x1="700" y1="140" x2="440" y2="140" class="arrow dash"/>
<text x="570" y="135" class="c sub mono" style="fill:#444">ServerHello + key_share</text>
<line x1="700" y1="172" x2="440" y2="172" class="arrow dash"/>
<text x="570" y="167" class="c sub mono" style="fill:#444">{EncryptedExtensions}</text>
<line x1="700" y1="204" x2="440" y2="204" class="arrow dash"/>
<text x="570" y="199" class="c sub mono" style="fill:#444">{Certificate}</text>
<line x1="700" y1="236" x2="440" y2="236" class="arrow dash"/>
<text x="570" y="231" class="c sub mono" style="fill:#444">{CertificateVerify}</text>
<text x="570" y="248" class="c sub">用私钥签名</text>
<line x1="700" y1="280" x2="440" y2="280" class="arrow dash"/>
<text x="570" y="275" class="c sub mono" style="fill:#444">{Finished}</text>
<line x1="440" y1="322" x2="700" y2="322" class="arrow green"/>
<text x="570" y="317" class="c sub mono" style="fill:#444">{Finished} + HTTP 请求</text>
<text x="570" y="452" class="c sub b" style="fill:#296898">1 个 RTT 后就能发送请求</text>
</svg>

After

Width:  |  Height:  |  Size: 5.1 KiB