aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt4
-rw-r--r--examples/ssl/example_ssl.cpp27
2 files changed, 31 insertions, 0 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 1350865..22139ad 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -11,6 +11,10 @@ add_executable(helloworld helloworld.cpp)
target_link_libraries(helloworld ${Boost_LIBRARIES})
target_link_libraries(helloworld ${CMAKE_THREAD_LIBS_INIT})
+add_executable(example_ssl ssl/example_ssl.cpp)
+target_link_libraries(example_ssl ${Boost_LIBRARIES})
+target_link_libraries(example_ssl ${CMAKE_THREAD_LIBS_INIT} ssl crypto)
+
add_executable(example example.cpp)
#target_link_libraries(example crow)
target_link_libraries(example ${Boost_LIBRARIES})
diff --git a/examples/ssl/example_ssl.cpp b/examples/ssl/example_ssl.cpp
new file mode 100644
index 0000000..601aa57
--- /dev/null
+++ b/examples/ssl/example_ssl.cpp
@@ -0,0 +1,27 @@
+#define CROW_ENABLE_SSL
+#include "crow.h"
+
+int main()
+{
+ crow::SimpleApp app;
+
+ CROW_ROUTE(app, "/")
+ ([]() {
+ return "Hello world!";
+ });
+
+ app.port(18080).ssl_file("test.crt", "test.key").run();
+
+ // Use .pem file
+ //app.port(18080).ssl_file("test.pem").run();
+
+ // Use custom context; see boost::asio::ssl::context
+ /*
+ * crow::ssl_context_t ctx;
+ * ctx.set_verify_mode(...)
+ *
+ * ... configuring ctx
+ *
+ * app.port(18080).ssl(ctx).run();
+ */
+}