OpenSSL自签证书

OpenSSL自签证书

1.OpenSSL自签证书

1.1 创建http.ext文件

需要指定要访问的IP,内容如下:

keyUsage = nonRepudiation, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth, clientAuth
subjectAltName=@SubjectAlternativeName

[SubjectAlternativeName]
IP.1=127.0.0.1
IP.2=192.168.1.2 

1.2 生成密钥

openssl req -new -newkey rsa:2048 -sha256 -nodes -out 192.168.1.2.csr -keyout 192.168.1.2.key -subj "/C=CN/ST=Beijing/L=Beijing/O=Super Inc./OU=Web Security/CN=192.168.1.2"

1.3 生成证书

openssl x509 -req -days 3650 -in 192.168.1.2.csr -signkey 192.168.1.2.key -out 192.168.1.2.crt -extfile http.ext

1.4 将证书打包为pkcs12格式

openssl pkcs12 -export -in 192.168.1.2.crt -inkey 192.168.1.2.key -out 192.168.1.2.p12 -name bsoft-media

1.5 导出pem格式证书

openssl pkcs12 -in 192.168.1.2.p12 -out 192.168.1.2.pem -nodes

运行此命令后,您将被要求输入 .p12 文件的密码。然后,OpenSSL 将提取证书和私钥,并将其保存到 .pem 文件中。 -nodes 选项表示不加密私钥。

2. 在本地谷歌浏览器安装证书

在谷歌浏览器[设置]->[隐私和安全]->[安全]->[证书管理]导入证书

点击[导入]导入证书

 清除浏览器缓存

最后把国标平台重新加载192.168.1.2.p12证书文件

3.访问

 链接是安全的:

 

posted @ 2024-03-28 18:37  钟齐峰  阅读(7)  评论(0编辑  收藏  举报