Skip to content

Commit 80c05e4

Browse files
committed
Merge pull request cpp-netlib#610 from ckaminski/master
Adding ssl_server example to default build
2 parents 406caef + c33756e commit 80c05e4

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

libs/network/example/CMakeLists.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ add_executable(hello_world_server http/hello_world_server.cpp)
1717
add_executable(hello_world_client http/hello_world_client.cpp)
1818
add_executable(hello_world_async_server_with_work_queue http/hello_world_async_server_with_work_queue.cpp)
1919
add_executable(trivial_google trivial_google.cpp)
20+
2021
if (UNIX)
2122
add_executable(fileserver http/fileserver.cpp)
2223
endif (UNIX)
@@ -66,6 +67,17 @@ target_link_libraries(hello_world_async_server_with_work_queue
6667
cppnetlib-client-connections
6768
cppnetlib-server-parsers)
6869

70+
if (OPENSSL_FOUND)
71+
add_executable(ssl_server http/ssl/ssl_server.cpp)
72+
add_dependencies(ssl_server cppnetlib-uri cppnetlib-client-connections)
73+
target_link_libraries(ssl_server
74+
${CMAKE_THREAD_LIBS_INIT}
75+
cppnetlib-server-parsers
76+
cppnetlib-uri
77+
cppnetlib-client-connections)
78+
endif (OPENSSL_FOUND)
79+
80+
6981
if (OPENSSL_FOUND)
7082
target_link_libraries(http_client ${OPENSSL_LIBRARIES})
7183
target_link_libraries(simple_wget ${OPENSSL_LIBRARIES})
@@ -74,6 +86,7 @@ if (OPENSSL_FOUND)
7486
target_link_libraries(hello_world_server ${OPENSSL_LIBRARIES})
7587
target_link_libraries(hello_world_client ${OPENSSL_LIBRARIES})
7688
target_link_libraries(hello_world_async_server_with_work_queue ${OPENSSL_LIBRARIES})
89+
target_link_libraries(ssl_server ${OPENSSL_LIBRARIES})
7790
target_link_libraries(trivial_google ${OPENSSL_LIBRARIES})
7891
endif (OPENSSL_FOUND)
7992

@@ -85,6 +98,7 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU AND ${CMAKE_SYSTEM_NAME} MATCHES "Windo
8598
target_link_libraries(hello_world_server ws2_32 wsock32)
8699
target_link_libraries(hello_world_client ws2_32)
87100
target_link_libraries(hello_world_async_server_with_work_queue ws2_32 wsock32)
101+
target_link_libraries(ssl_server ws2_32 wsock32)
88102
target_link_libraries(trivial_google ws2_32)
89103
endif()
90104

@@ -97,6 +111,9 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
97111
target_link_libraries(hello_world_client rt)
98112
target_link_libraries(hello_world_async_server_with_work_queue rt)
99113
target_link_libraries(trivial_google rt)
114+
if (OPENSSL_FOUND)
115+
target_link_libraries(ssl_server rt)
116+
endif (OPENSSL_FOUND)
100117
endif()
101118

102119
if (UNIX)
@@ -119,7 +136,10 @@ set_target_properties(trivial_google PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-N
119136
set_target_properties(hello_world_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
120137
set_target_properties(hello_world_client PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
121138
set_target_properties(hello_world_async_server_with_work_queue PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
122-
139+
if (OPENSSL_FOUND)
140+
set_target_properties(ssl_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
141+
endif (OPENSSL_FOUND)
142+
123143
if (UNIX)
124144
set_target_properties(fileserver PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CPP-NETLIB_BINARY_DIR}/example)
125145
endif (UNIX)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-----BEGIN DH PARAMETERS-----
2+
MIIBCAKCAQEA1wI+wQdLMRtQK+0EIXNg+g+J/EhIZedqdkSKKLIdclDAjUdbnDWJ
3+
rMR76tKGItPb0LkWHfxJkrziyvZRO2KWTThQ1Tz05x+OgM2ckHT+QsTxNqOosvdT
4+
pOtMt260WaXVYvHJ0CZgTo7+DUcXNYZW/xvSW206RW9oJIgqCFrhUrKGpVFuqLZZ
5+
Nwjy62Ueg3TUwE5D5K0xgUjyCAuHZmeI2uQUbJS6u9GeraV5h0QtH3njDS6mD64v
6+
cN5MqQXO1UTl4sQUhDPamyiJz57/o/jinHJUDLz1FGS8kOR8ecYAx8JryFgm4qPd
7+
+MYaDDIJku8f19Rnjb1SI/Y28uHL9X2dswIBAg==
8+
-----END DH PARAMETERS-----

libs/network/example/http/ssl/dh512.pem

Lines changed: 0 additions & 12 deletions
This file was deleted.

libs/network/example/http/ssl/ssl_server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <signal.h>
2020

2121
struct handler;
22-
typedef boost::network::http::async_server<handler> server;
22+
typedef boost::network::http::server<handler> server;
2323

2424
std::string password_callback(
2525
std::size_t max_length,
@@ -78,7 +78,7 @@ int main(void) try {
7878
ctx->set_password_callback(password_callback);
7979
ctx->use_certificate_chain_file("server.pem");
8080
ctx->use_private_key_file("server.pem", asio::ssl::context::pem);
81-
ctx->use_tmp_dh_file("dh512.pem");
81+
ctx->use_tmp_dh_file("dh2048.pem");
8282

8383
// setup the async server
8484
handler request_handler;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy