Changeset - 8ef6fb320ae8
[Not reviewed]
0 2 0
Vitaly Takmazov - 9 years ago 2016-04-27 13:16:49
vitalyster@gmail.com
spectrum2_manager: enable SSL only when using OpenSSL library
2 files changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
spectrum_manager/src/CMakeLists.txt
Show inline comments
 
@@ -4,14 +4,15 @@ FILE(GLOB SRC *.cpp *.c)
 
ADD_EXECUTABLE(spectrum2_manager ${SRC})
 

	
 
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()
 

	
 
if(APPLE)
 
target_link_libraries(spectrum2_manager transport ${APPLE_FRAMEWORKS})
spectrum_manager/src/server.cpp
Show inline comments
 
@@ -72,20 +72,21 @@ Server::Server(ManagerConfig *config, const std::string &config_file) {
 
	opts.error_string = &error_string;
 
	m_nc = mg_bind_opt(&m_mgr, std::string(":" + boost::lexical_cast<std::string>(CONFIG_INT(m_config, "service.port"))).c_str(), &_event_handler, opts);
 
	if (!m_nc) {
 
		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) {
 
			std::cerr << "Error setting SSL certificate: " << err_str << "\n";
 
			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();
 

	
 
	std::ifstream header(std::string(CONFIG_STRING(m_config, "service.data_dir") + "/header.html").c_str(), std::ios::in);
 
	if (header) {
0 comments (0 inline, 0 general)