aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJaeseung Ha <ipknhama@gmail.com>2015-09-20 22:06:00 +0900
committerJaeseung Ha <ipknhama@gmail.com>2015-09-20 22:06:00 +0900
commite4708671bcfd2514edaa1a8e0bd5fa58f00c5fd1 (patch)
treeb47fc83d73c9b6031f75e576e8e633b93eee8901 /examples
parent5282c9d4aae7ae1450a76fa29ddf837c8eb2f56d (diff)
downloadcrow-e4708671bcfd2514edaa1a8e0bd5fa58f00c5fd1.tar.gz
crow-e4708671bcfd2514edaa1a8e0bd5fa58f00c5fd1.zip
implement HTTPS support
- define CROW_ENABLE_SSL to use - close #88
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();
+ */
+}