Skip to content

Adding ssl_server example to default build #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion libs/network/example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ add_executable(hello_world_server http/hello_world_server.cpp)
add_executable(hello_world_client http/hello_world_client.cpp)
add_executable(hello_world_async_server_with_work_queue http/hello_world_async_server_with_work_queue.cpp)
add_executable(trivial_google trivial_google.cpp)

if (UNIX)
add_executable(fileserver http/fileserver.cpp)
endif (UNIX)
Expand Down Expand Up @@ -66,6 +67,17 @@ target_link_libraries(hello_world_async_server_with_work_queue
cppnetlib-client-connections
cppnetlib-server-parsers)

if (OPENSSL_FOUND)
add_executable(ssl_server http/ssl/ssl_server.cpp)
add_dependencies(ssl_server cppnetlib-uri cppnetlib-client-connections)
target_link_libraries(ssl_server
${CMAKE_THREAD_LIBS_INIT}
cppnetlib-server-parsers
cppnetlib-uri
cppnetlib-client-connections)
endif (OPENSSL_FOUND)


if (OPENSSL_FOUND)
target_link_libraries(http_client ${OPENSSL_LIBRARIES})
target_link_libraries(simple_wget ${OPENSSL_LIBRARIES})
Expand All @@ -74,6 +86,7 @@ if (OPENSSL_FOUND)
target_link_libraries(hello_world_server ${OPENSSL_LIBRARIES})
target_link_libraries(hello_world_client ${OPENSSL_LIBRARIES})
target_link_libraries(hello_world_async_server_with_work_queue ${OPENSSL_LIBRARIES})
target_link_libraries(ssl_server ${OPENSSL_LIBRARIES})
target_link_libraries(trivial_google ${OPENSSL_LIBRARIES})
endif (OPENSSL_FOUND)

Expand All @@ -85,6 +98,7 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU AND ${CMAKE_SYSTEM_NAME} MATCHES "Windo
target_link_libraries(hello_world_server ws2_32 wsock32)
target_link_libraries(hello_world_client ws2_32)
target_link_libraries(hello_world_async_server_with_work_queue ws2_32 wsock32)
target_link_libraries(ssl_server ws2_32 wsock32)
target_link_libraries(trivial_google ws2_32)
endif()

Expand All @@ -97,6 +111,9 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(hello_world_client rt)
target_link_libraries(hello_world_async_server_with_work_queue rt)
target_link_libraries(trivial_google rt)
if (OPENSSL_FOUND)
target_link_libraries(ssl_server rt)
endif (OPENSSL_FOUND)
endif()

if (UNIX)
Expand All @@ -119,7 +136,10 @@ set_target_properties(trivial_google PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-N
set_target_properties(hello_world_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(hello_world_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
set_target_properties(hello_world_async_server_with_work_queue PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)

if (OPENSSL_FOUND)
set_target_properties(ssl_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
endif (OPENSSL_FOUND)

if (UNIX)
set_target_properties(fileserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
endif (UNIX)
8 changes: 8 additions & 0 deletions libs/network/example/http/ssl/dh2048.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEA1wI+wQdLMRtQK+0EIXNg+g+J/EhIZedqdkSKKLIdclDAjUdbnDWJ
rMR76tKGItPb0LkWHfxJkrziyvZRO2KWTThQ1Tz05x+OgM2ckHT+QsTxNqOosvdT
pOtMt260WaXVYvHJ0CZgTo7+DUcXNYZW/xvSW206RW9oJIgqCFrhUrKGpVFuqLZZ
Nwjy62Ueg3TUwE5D5K0xgUjyCAuHZmeI2uQUbJS6u9GeraV5h0QtH3njDS6mD64v
cN5MqQXO1UTl4sQUhDPamyiJz57/o/jinHJUDLz1FGS8kOR8ecYAx8JryFgm4qPd
+MYaDDIJku8f19Rnjb1SI/Y28uHL9X2dswIBAg==
-----END DH PARAMETERS-----
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no security expert, but is this good to do, committing this into the repo?

12 changes: 0 additions & 12 deletions libs/network/example/http/ssl/dh512.pem

This file was deleted.

4 changes: 2 additions & 2 deletions libs/network/example/http/ssl/ssl_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <signal.h>

struct handler;
typedef boost::network::http::async_server<handler> server;
typedef boost::network::http::server<handler> server;

std::string password_callback(
std::size_t max_length,
Expand Down Expand Up @@ -78,7 +78,7 @@ int main(void) try {
ctx->set_password_callback(password_callback);
ctx->use_certificate_chain_file("server.pem");
ctx->use_private_key_file("server.pem", asio::ssl::context::pem);
ctx->use_tmp_dh_file("dh512.pem");
ctx->use_tmp_dh_file("dh2048.pem");

// setup the async server
handler request_handler;
Expand Down