From 9be141a1e059e02a178a5da690d7e6e63f363abb Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sat, 17 Jun 2017 12:02:25 -0700 Subject: [PATCH] Reorganize SSL examples --- CHANGELOG.md | 1 + CMakeLists.txt | 3 +- doc/2_examples.qbk | 4 +- example/Jamfile | 4 ++ example/ssl-http-client/CMakeLists.txt | 14 ++++++ .../Jamfile.v2 => ssl-http-client/Jamfile} | 9 +--- .../ssl_http_client.cpp} | 0 example/ssl-websocket-client/CMakeLists.txt | 14 ++++++ example/ssl-websocket-client/Jamfile | 49 +++++++++++++++++++ .../ssl_websocket_client.cpp} | 0 example/ssl/CMakeLists.txt | 24 --------- 11 files changed, 88 insertions(+), 34 deletions(-) create mode 100644 example/ssl-http-client/CMakeLists.txt rename example/{ssl/Jamfile.v2 => ssl-http-client/Jamfile} (85%) rename example/{ssl/http_ssl_example.cpp => ssl-http-client/ssl_http_client.cpp} (100%) create mode 100644 example/ssl-websocket-client/CMakeLists.txt create mode 100644 example/ssl-websocket-client/Jamfile rename example/{ssl/websocket_ssl_example.cpp => ssl-websocket-client/ssl_websocket_client.cpp} (100%) delete mode 100644 example/ssl/CMakeLists.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 224af41a..55a4f753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 61: * Remove Spirit dependency * Use generic_cateogry for errno +* Reorganize SSL examples -------------------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 56984eb0..77dd4cda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,6 +185,7 @@ add_subdirectory (example) if (NOT OPENSSL_FOUND) message("OpenSSL not found. Not building SSL tests and examples") else() - add_subdirectory (example/ssl) + add_subdirectory (example/ssl-http-client) + add_subdirectory (example/ssl-websocket-client) add_subdirectory (test/websocket/ssl) endif() diff --git a/doc/2_examples.qbk b/doc/2_examples.qbk index d22759a6..b2576952 100644 --- a/doc/2_examples.qbk +++ b/doc/2_examples.qbk @@ -57,7 +57,7 @@ as measured by Alexa. This example demonstrates sending and receiving HTTP messages over a TLS connection. Requires OpenSSL to build. -* [repo_file example/ssl/http_ssl_example.cpp] +* [repo_file example/ssl-http-client/ssl_http_client.cpp] [endsect] @@ -68,7 +68,7 @@ over a TLS connection. Requires OpenSSL to build. Establish a WebSocket connection over an encrypted TLS connection, send a message and receive the reply. Requires OpenSSL to build. -* [repo_file example/ssl/websocket_ssl_example.cpp] +* [repo_file example/ssl-websocket-client/ssl_websocket_client.cpp] [endsect] diff --git a/example/Jamfile b/example/Jamfile index 4f6aa2ba..00d289a1 100644 --- a/example/Jamfile +++ b/example/Jamfile @@ -10,3 +10,7 @@ build-project http-client ; build-project http-crawl ; build-project server-framework ; build-project websocket-client ; + +# VFALCO How do I make this work on Windows and if OpenSSL is not available? +#build-project ssl-http-client ; +#build-project ssl-websocket-client ; diff --git a/example/ssl-http-client/CMakeLists.txt b/example/ssl-http-client/CMakeLists.txt new file mode 100644 index 00000000..d7d18e9c --- /dev/null +++ b/example/ssl-http-client/CMakeLists.txt @@ -0,0 +1,14 @@ +# Part of Beast + +GroupSources(include/beast beast) + +GroupSources(example/ssl-http-client "/") + +include_directories(${OPENSSL_INCLUDE_DIR}) + +add_executable (ssl-http-client + ${BEAST_INCLUDES} + ssl_http_client.cpp +) + +target_link_libraries(ssl-http-client Beast ${OPENSSL_LIBRARIES}) diff --git a/example/ssl/Jamfile.v2 b/example/ssl-http-client/Jamfile similarity index 85% rename from example/ssl/Jamfile.v2 rename to example/ssl-http-client/Jamfile index 45ab791f..aaae4689 100644 --- a/example/ssl/Jamfile.v2 +++ b/example/ssl-http-client/Jamfile @@ -43,12 +43,7 @@ project crypto ; -exe http-ssl-example +exe ssl-http-client : - http_ssl_example.cpp - ; - -exe websocket-ssl-example - : - websocket_ssl_example.cpp + ssl_http_client.cpp ; diff --git a/example/ssl/http_ssl_example.cpp b/example/ssl-http-client/ssl_http_client.cpp similarity index 100% rename from example/ssl/http_ssl_example.cpp rename to example/ssl-http-client/ssl_http_client.cpp diff --git a/example/ssl-websocket-client/CMakeLists.txt b/example/ssl-websocket-client/CMakeLists.txt new file mode 100644 index 00000000..19abb422 --- /dev/null +++ b/example/ssl-websocket-client/CMakeLists.txt @@ -0,0 +1,14 @@ +# Part of Beast + +GroupSources(include/beast beast) + +GroupSources(example/ssl-websocket-client "/") + +include_directories(${OPENSSL_INCLUDE_DIR}) + +add_executable (ssl-websocket-client + ${BEAST_INCLUDES} + ssl_websocket_client.cpp +) + +target_link_libraries(ssl-websocket-client Beast ${OPENSSL_LIBRARIES}) diff --git a/example/ssl-websocket-client/Jamfile b/example/ssl-websocket-client/Jamfile new file mode 100644 index 00000000..ca5adf32 --- /dev/null +++ b/example/ssl-websocket-client/Jamfile @@ -0,0 +1,49 @@ +# +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +# +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# + +import os ; + +if [ os.name ] = SOLARIS +{ + lib socket ; + lib nsl ; +} +else if [ os.name ] = NT +{ + lib ws2_32 ; + lib mswsock ; +} +else if [ os.name ] = HPUX +{ + lib ipv6 ; +} +else if [ os.name ] = HAIKU +{ + lib network ; +} + +if [ os.name ] = NT +{ + lib ssl : : ssleay32 ; + lib crypto : : libeay32 ; +} +else +{ + lib ssl ; + lib crypto ; +} + +project + : requirements + ssl + crypto + ; + +exe ssl-websocket-client + : + ssl_websocket_client.cpp + ; diff --git a/example/ssl/websocket_ssl_example.cpp b/example/ssl-websocket-client/ssl_websocket_client.cpp similarity index 100% rename from example/ssl/websocket_ssl_example.cpp rename to example/ssl-websocket-client/ssl_websocket_client.cpp diff --git a/example/ssl/CMakeLists.txt b/example/ssl/CMakeLists.txt deleted file mode 100644 index 44963f08..00000000 --- a/example/ssl/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# Part of Beast - -GroupSources(extras/beast extras) -GroupSources(include/beast beast) - -GroupSources(example/ssl "/") - -include_directories(${OPENSSL_INCLUDE_DIR}) - -add_executable (http-ssl-example - ${BEAST_INCLUDES} - ${EXTRAS_INCLUDES} - http_ssl_example.cpp -) - -target_link_libraries(http-ssl-example Beast ${OPENSSL_LIBRARIES}) - -add_executable (websocket-ssl-example - ${BEAST_INCLUDES} - ${EXTRAS_INCLUDES} - websocket_ssl_example.cpp -) - -target_link_libraries(websocket-ssl-example Beast ${OPENSSL_LIBRARIES})