配置客户端与 API7 网关之间的 mTLS
双向传输层安全性(mTLS),作为 TLS(传输层安全性)的一种高级应用,旨在通过客户端与服务器之间的双向身份验证机制,显著提升通信安全性。这一过程依赖于精心设计的握手流程,双方不仅交换加密密钥,还相互验证对方的数字证书,从而确保通信双方身份的准确无误。
本指南将阐述如何在客户端应用程序和 API7 企业版之间配置 mTLS,以有效阻止未经授权的访问并加固整体安全防线。
下面是一个互动演示,提供配置 mTLS 的实践入门。通过点击并按照步骤操作,你将更好地了解如何在 API7 企业版中使用。
前提条件
生成证书和密钥
-
生成证书颁发机构(CA)的密钥和证书。
openssl genrsa -out ca.key 2048 && \
openssl req -new -sha256 -key ca.key -out ca.csr -subj "/CN=ROOTCA" && \
openssl x509 -req -days 36500 -sha256 -extensions v3_ca -signkey ca.key -in ca.csr -out ca.crt -
为 API7 企业版生成一个公用名为
test.com
的密钥和证书,并使用 CA 证书签名。openssl genrsa -out server.key 2048 && \
openssl req -new -sha256 -key server.key -out server.csr -subj "/CN=test.com" && \
openssl x509 -req -days 36500 -sha256 -extensions v3_req \
-CA ca.crt -CAkey ca.key -CAserial ca.srl -CAcreateserial \
-in server.csr -out server.crt -
为客户端生成一个公用名为
CLIENT
的密钥和证 书,并使用 CA 证书签名。openssl genrsa -out client.key 2048 && \
openssl req -new -sha256 -key client.key -out client.csr -subj "/CN=CLIENT" && \
openssl x509 -req -days 36500 -sha256 -extensions v3_req \
-CA ca.crt -CAkey ca.key -CAserial ca.srl -CAcreateserial \
-in client.csr -out client.crt -
生成证书和密钥后,检查并确保以下文件已保存至你的本地设备。
❶
server.crt
: 服务器证书❷
server.key
: 服务器证书的密钥❸
ca.crt
: CA 证书
为 API7 企业版配置 mTLS
-
从侧边栏选择网关组的 SSL 证书,然后点击 + 新增 SSL 证书。
-
在对话框中,执行以下操作:
- 类型 选择
服务器
。 - 选择 上传 方法。