From ddfc2732cd76068f02c0023f7b22c62599e9f0ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=A5=9A?= <771730766@qq.com> Date: Mon, 1 Feb 2021 17:29:59 +0800 Subject: [PATCH] =?UTF-8?q?Created=20=E7=94=9F=E6=88=90SSL=E8=87=AA?= =?UTF-8?q?=E7=AD=BE=E5=90=8D=E8=AF=81=E4=B9=A6=E5=B9=B6=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=20(markdown)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 生成SSL自签名证书并测试.md | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 生成SSL自签名证书并测试.md diff --git a/生成SSL自签名证书并测试.md b/生成SSL自签名证书并测试.md new file mode 100644 index 0000000..d4708d8 --- /dev/null +++ b/生成SSL自签名证书并测试.md @@ -0,0 +1,47 @@ +# 1、创建私钥 +```bash + openssl genrsa -out server.key 2048 +``` + +# 2、 创建签名请求文件 +```bash + openssl req -new -key server.key -out server.csr +``` +注意,需要输入域名(Common Name (e.g. server FQDN or YOUR name)): +```bash +Country Name (2 letter code) [AU]:cn +State or Province Name (full name) [Some-State]:gd +Locality Name (eg, city) []:sz +Organization Name (eg, company) [Internet Widgits Pty Ltd]:company +Organizational Unit Name (eg, section) []:section +Common Name (e.g. server FQDN or YOUR name) []:zlm.com +Email Address []:xiachu@qq.com + +Please enter the following 'extra' attributes +to be sent with your certificate request +A challenge password []: +An optional company name []:zlm +``` + +# 3、自签名,生成公钥(10年有效期) +```bash +openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt +``` +执行该命令会打印以下信息: +```bash +Signature ok +subject=/C=cn/ST=gd/L=sz/O=company/OU=section/CN=zlm.com/emailAddress=xiachu@qq.com +Getting Private key +``` + +# 4、合并公钥私钥 +```bash +cat server.crt server.key > ./ssl.pem +``` + +# 5、加载证书 +```bash +./MediaServer -s ./ssl.pem +``` +![图片.png](https://upload-images.jianshu.io/upload_images/8409177-a3e64c0c8b642521.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) +