自动复制证书至可执行目录

This commit is contained in:
xiongziliang 2019-04-01 10:37:11 +08:00
parent 9247cb9571
commit d1f722939d
5 changed files with 8 additions and 23 deletions

@ -1 +1 @@
Subproject commit 086b14bdc9924f7f86f53d0fa542b8568bff5bc8 Subproject commit e79d24b51051ed9b3bd9c66b9d8ace3c76a0411a

View File

@ -1,4 +1,6 @@
#SDL2 execute_process(COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/ssl.pem ${EXECUTABLE_OUTPUT_PATH}/)
#SDL2
find_package(SDL2 QUIET) find_package(SDL2 QUIET)
if (SDL2_FOUND) if (SDL2_FOUND)
include_directories(${SDL2_INCLUDE_DIR}) include_directories(${SDL2_INCLUDE_DIR})

View File

@ -112,26 +112,16 @@ int main(int argc,char *argv[]){
//加载配置文件,如果配置文件不存在就创建一个 //加载配置文件,如果配置文件不存在就创建一个
loadIniConfig(); loadIniConfig();
#ifdef ENABLE_OPENSSL //加载证书,证书包含公钥和私钥
//请把证书"test_httpApi.pem"放置在本程序可执行程序同目录下 SSL_Initor::Instance().loadServerPem((exeDir() + "ssl.pem").data());
try{
//加载证书,证书包含公钥和私钥
SSL_Initor::Instance().loadServerPem((exePath() + ".pem").data());
}catch(...){
ErrorL << "请把证书:" << (exeName() + ".pem") << "放置在本程序可执行程序同目录下:" << exeDir() << endl;
return 0;
}
#endif //ENABLE_OPENSSL
//开启http服务器 //开启http服务器
TcpServer::Ptr httpSrv(new TcpServer()); TcpServer::Ptr httpSrv(new TcpServer());
httpSrv->start<EchoWebSocketSession>(mINI::Instance()[Http::kPort]);//默认80 httpSrv->start<EchoWebSocketSession>(mINI::Instance()[Http::kPort]);//默认80
#ifdef ENABLE_OPENSSL
//如果支持ssl还可以开启https服务器 //如果支持ssl还可以开启https服务器
TcpServer::Ptr httpsSrv(new TcpServer()); TcpServer::Ptr httpsSrv(new TcpServer());
httpsSrv->start<SSLEchoWebSocketSession>(mINI::Instance()[Http::kSSLPort]);//默认443 httpsSrv->start<SSLEchoWebSocketSession>(mINI::Instance()[Http::kSSLPort]);//默认443
#endif //ENABLE_OPENSSL
InfoL << "你可以在浏览器输入:http://127.0.0.1/api/my_api?key0=val0&key1=参数1" << endl; InfoL << "你可以在浏览器输入:http://127.0.0.1/api/my_api?key0=val0&key1=参数1" << endl;

View File

@ -274,15 +274,8 @@ int main(int argc,char *argv[]) {
" rtsp地址 : rtsp://127.0.0.1/live/0\n" " rtsp地址 : rtsp://127.0.0.1/live/0\n"
" rtmp地址 : rtmp://127.0.0.1/live/0"; " rtmp地址 : rtmp://127.0.0.1/live/0";
//请把证书"test_server.pem"放置在本程序可执行程序同目录下 //加载证书,证书包含公钥和私钥
try { SSL_Initor::Instance().loadServerPem((exeDir() + "ssl.pem").data());
//加载证书,证书包含公钥和私钥
SSL_Initor::Instance().loadServerPem((exePath() + ".pem").data());
} catch (...) {
ErrorL << "请把证书:" << (exeName() + ".pem") << "放置在本程序可执行程序同目录下:" << exeDir() << endl;
proxyMap.clear();
return 0;
}
uint16_t shellPort = mINI::Instance()[Shell::kPort]; uint16_t shellPort = mINI::Instance()[Shell::kPort];
uint16_t rtspPort = mINI::Instance()[Rtsp::kPort]; uint16_t rtspPort = mINI::Instance()[Rtsp::kPort];