# OpenSSL双向证书 **Published by:** [MarkTang's Blog](https://paragraph.com/@marktang-s-blog/) **Published on:** 2022-08-26 **URL:** https://paragraph.com/@marktang-s-blog/openssl ## Content 时间戳鉴权加密方式加密密钥: 123456 (存在本地加密) 加密方式: AES 模式: CBC 填充补全码: Pkcs7 密文编码: Base64 iv偏移量: 123456 (跟密钥相同) token请求头字段名: Access-Token加密流程获取服务器当前时间时间戳时间戳转成字节数组分组密钥获取密钥块长度,利用需要加密的内容的字节数组+密钥块长度 Pkcs7方式生成补全码利用 分组密钥+iv偏移量 创建CBC加密模式创建补全码长度的 字节数组用于待会儿保存加密后字节数组利用补全码进行CBC加密,加密字节保存到上方创建的字节数组中对字节数组密文进行base64编码,将该字符串存入请求头(Headers)的Access-Token中例:生成根证书私钥 root-key.key生成根证书请求文件 根据root-key.key -> root-req.csr自签根证书 根据root-req.csr、root-key.key -> root-cert.cer (设置过期时间365)生成p12格式根证书 根据root-cert.cer、root-key.key -> root.p12生成服务端证书私钥 server-key.key生成服务端证书请求文件 根据server-key.key -> server-req.csr (绑定服务端域名)生成服务端证书 (root证书(root-cert.cer)、rootKey(root-key.key)、服务端Key(server-key.key)、服务端请求文件(server-req.csr),用这4个文件生成服务端证书) -> server-cert.cer生成客户端证书私钥 client-key.key生成客户端证书请求文件 根据client-key.key -> client-req.csr生成客户端证书 (root证书(root-cert.cer)、rootKey(root-key.key)、客户端Key(client-key.key)、客户端请求文件(client-req.csr), 用这4个文件生成客户端证书) -> client-cert.cer生成客户端p12格式根证书 根据client-cert.cer、client-key.key -> client.p12 ## Publication Information - [MarkTang's Blog](https://paragraph.com/@marktang-s-blog/): Publication homepage - [All Posts](https://paragraph.com/@marktang-s-blog/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@marktang-s-blog): Subscribe to updates - [Twitter](https://twitter.com/MarkTan43749744): Follow on Twitter