From d1f722939d24f2e16c4b58d917c1ef6734ecf04e Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 1 Apr 2019 10:37:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=A4=8D=E5=88=B6=E8=AF=81?= =?UTF-8?q?=E4=B9=A6=E8=87=B3=E5=8F=AF=E6=89=A7=E8=A1=8C=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZLToolKit | 2 +- tests/CMakeLists.txt | 4 +++- tests/{test_server.pem => ssl.pem} | 0 tests/test_httpApi.cpp | 14 ++------------ tests/test_server.cpp | 11 ++--------- 5 files changed, 8 insertions(+), 23 deletions(-) rename tests/{test_server.pem => ssl.pem} (100%) diff --git a/ZLToolKit b/ZLToolKit index 086b14bd..e79d24b5 160000 --- a/ZLToolKit +++ b/ZLToolKit @@ -1 +1 @@ -Subproject commit 086b14bdc9924f7f86f53d0fa542b8568bff5bc8 +Subproject commit e79d24b51051ed9b3bd9c66b9d8ace3c76a0411a diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index eccecd5d..6301f927 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,6 @@ -#查找SDL2是否安装 +execute_process(COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/ssl.pem ${EXECUTABLE_OUTPUT_PATH}/) + +#查找SDL2是否安装 find_package(SDL2 QUIET) if (SDL2_FOUND) include_directories(${SDL2_INCLUDE_DIR}) diff --git a/tests/test_server.pem b/tests/ssl.pem similarity index 100% rename from tests/test_server.pem rename to tests/ssl.pem diff --git a/tests/test_httpApi.cpp b/tests/test_httpApi.cpp index bb5aed49..2bbc6642 100644 --- a/tests/test_httpApi.cpp +++ b/tests/test_httpApi.cpp @@ -112,26 +112,16 @@ int main(int argc,char *argv[]){ //加载配置文件,如果配置文件不存在就创建一个 loadIniConfig(); -#ifdef ENABLE_OPENSSL - //请把证书"test_httpApi.pem"放置在本程序可执行程序同目录下 - try{ - //加载证书,证书包含公钥和私钥 - SSL_Initor::Instance().loadServerPem((exePath() + ".pem").data()); - }catch(...){ - ErrorL << "请把证书:" << (exeName() + ".pem") << "放置在本程序可执行程序同目录下:" << exeDir() << endl; - return 0; - } -#endif //ENABLE_OPENSSL + //加载证书,证书包含公钥和私钥 + SSL_Initor::Instance().loadServerPem((exeDir() + "ssl.pem").data()); //开启http服务器 TcpServer::Ptr httpSrv(new TcpServer()); httpSrv->start(mINI::Instance()[Http::kPort]);//默认80 -#ifdef ENABLE_OPENSSL //如果支持ssl,还可以开启https服务器 TcpServer::Ptr httpsSrv(new TcpServer()); httpsSrv->start(mINI::Instance()[Http::kSSLPort]);//默认443 -#endif //ENABLE_OPENSSL InfoL << "你可以在浏览器输入:http://127.0.0.1/api/my_api?key0=val0&key1=参数1" << endl; diff --git a/tests/test_server.cpp b/tests/test_server.cpp index 84f54d2c..f7d572a3 100644 --- a/tests/test_server.cpp +++ b/tests/test_server.cpp @@ -274,15 +274,8 @@ int main(int argc,char *argv[]) { " rtsp地址 : rtsp://127.0.0.1/live/0\n" " rtmp地址 : rtmp://127.0.0.1/live/0"; - //请把证书"test_server.pem"放置在本程序可执行程序同目录下 - try { - //加载证书,证书包含公钥和私钥 - SSL_Initor::Instance().loadServerPem((exePath() + ".pem").data()); - } catch (...) { - ErrorL << "请把证书:" << (exeName() + ".pem") << "放置在本程序可执行程序同目录下:" << exeDir() << endl; - proxyMap.clear(); - return 0; - } + //加载证书,证书包含公钥和私钥 + SSL_Initor::Instance().loadServerPem((exeDir() + "ssl.pem").data()); uint16_t shellPort = mINI::Instance()[Shell::kPort]; uint16_t rtspPort = mINI::Instance()[Rtsp::kPort];