spectrum2_manager: enable SSL only when using OpenSSL library

This commit is contained in:
Vitaly Takmazov 2016-04-27 14:16:49 +03:00
parent fe69cbd7a1
commit 8ef6fb320a
2 changed files with 4 additions and 2 deletions

View file

@ -7,8 +7,9 @@ ADD_DEPENDENCIES(spectrum2_manager pb)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/../../include/transport/protocol.pb.cc PROPERTIES GENERATED 1)
target_link_libraries(spectrum2_manager transport ${SWIFTEN_LIBRARY} ${PROTOBUF_LIBRARIES})
if (${OPENSSL_FOUND})
add_definitions(-DMG_ENABLE_SSL)
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(spectrum2_manager ${OPENSSL_LIBRARIES})
endif()

View file

@ -75,7 +75,7 @@ Server::Server(ManagerConfig *config, const std::string &config_file) {
std::cerr << "Error creating server: " << error_string << "\n";
exit(1);
}
#ifdef MG_ENABLE_SSL
if (!CONFIG_STRING(m_config, "service.cert").empty()) {
const char *err_str = mg_set_ssl(m_nc, CONFIG_STRING(m_config, "service.cert").c_str(), NULL);
if (err_str) {
@ -83,6 +83,7 @@ Server::Server(ManagerConfig *config, const std::string &config_file) {
exit(1);
}
}
#endif
mg_set_protocol_http_websocket(m_nc);
s_http_server_opts.document_root = CONFIG_STRING(m_config, "service.data_dir").c_str();