From b8e15dfe4972039ef19dbe9588a88170487a5434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=A5=9A?= <771730766@qq.com> Date: Fri, 23 Sep 2022 11:09:52 +0800 Subject: [PATCH] =?UTF-8?q?Created=20=E6=80=8E=E4=B9=88=E5=BC=80=E5=90=AFh?= =?UTF-8?q?ttps=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=20(markdown)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 怎么开启https相关功能.md | 77 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 怎么开启https相关功能.md diff --git a/怎么开启https相关功能.md b/怎么开启https相关功能.md new file mode 100644 index 0000000..477ade1 --- /dev/null +++ b/怎么开启https相关功能.md @@ -0,0 +1,77 @@ +## 一、编译时开启openssl特性 +zlmediakit的https(另外还包括rtmps/rtsps/webrtc/wss)功能依赖openssl库,在编译zlmediakit时,应该先在系统默认环境安装openssl库,ubuntu下通过以下命令安装: +```bash +sudo apt-get install libssl-dev +``` + +如果您的系统默认openssl版本太老,可以选择自行编译安装openssl到自定义路径;此时,在编译zlmediakit时可以通过以下命令指定openssl自定义安装路径: + +```bash +cd ZLMediaKit +mkdir build +cd build +cmake .. -DOPENSSL_ROOT_DIR=/path/to/your/new/openssl/install/root/dir +make -j$(nproc) +``` + +## 二、创建证书 +- 如果你还没购买域名,可以使用[自签名证书](https://github.com/ZLMediaKit/ZLMediaKit/wiki/%E7%94%9F%E6%88%90SSL%E8%87%AA%E7%AD%BE%E5%90%8D%E8%AF%81%E4%B9%A6%E5%B9%B6%E6%B5%8B%E8%AF%95)或zlmediakit自带默认证书`default.pem`测试。 + +- **如果你已经购买域名,以阿里云为例,你可以选择为您的域名申请免费证书:** + +![图片](https://user-images.githubusercontent.com/11495632/191882967-7a823548-8eb2-4419-bb3a-51a4dfef5c4e.png) + +- **申请免费证书额度后,可以点击`创建证书`按钮,在弹出页面输入您的域名:** + +![图片](https://user-images.githubusercontent.com/11495632/191883407-29b22a27-0763-452d-9e26-0d32f718b196.png) + +- **点击下一步后提交审核:** + +![图片](https://user-images.githubusercontent.com/11495632/191883676-e4315e6b-2d77-488c-a433-cb156fb75af9.png) + +## 三、下载证书并合并为zlmediakit支持的证书类型: +- **下载证书:** + +![图片](https://user-images.githubusercontent.com/11495632/191883919-ea64f77f-c170-4cc2-8284-04b386e2dea4.png) + +- **选择下载nginx或其他方式都可(两者证书类型一样):** + +![图片](https://user-images.githubusercontent.com/11495632/191884016-87192a79-8816-4ab0-b05c-b4384e26aa60.png) + +- **解压下载压缩包后文件如下**: + +图片 + + +- key后缀的文件是私钥,pem后缀的文件未公钥,两者可以使用文本编辑器打开,它们都是base64编码的字符串,两个字符串拼接在一起后就是zlmediakit支持的证书文件类型了: + +```bash +#进入文件夹 +cd 8516590_test.zlmediakit.com_nginx +#合并公钥私钥 +cat 8516590_test.zlmediakit.com.key 8516590_test.zlmediakit.com.pem > default.pem +``` + +## 四、zlmediakit加载证书 + +```bash +#进入zlmediakit编译后的二进制目录(不同平台路径有所不同) +cd ~/git/ZLMediaKit/release/darwin/Debug/ + +#把合并后的证书拷贝过来 +cp ~/Downloads/8516590_test.zlmediakit.com_nginx/default.pem ./ + +#启动进程 +./MediaServer -s default.com +``` + +![图片](https://user-images.githubusercontent.com/11495632/191885188-62cb4e02-3dbb-4142-a852-22a359a63680.png) + + + + + + + + +