Skip to content

Commit 9648f95

Browse files
committed
Updated README
1 parent 6b9ffc8 commit 9648f95

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

README.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,33 @@ res->body;
5353
1. Run server at https://repl.it/@yhirose/cpp-httplib-server
5454
2. Run client at https://repl.it/@yhirose/cpp-httplib-client
5555
56+
SSL Support
57+
-----------
58+
59+
SSL support is available with `CPPHTTPLIB_OPENSSL_SUPPORT`. `libssl` and `libcrypto` should be linked.
60+
61+
NOTE: cpp-httplib currently supports only version 1.1.1.
62+
63+
```c++
64+
#define CPPHTTPLIB_OPENSSL_SUPPORT
65+
#include "path/to/httplib.h"
66+
67+
// Server
68+
httplib::SSLServer svr("./cert.pem", "./key.pem");
69+
70+
// Client
71+
httplib::Client cli("https://localhost:1234"); // scheme + host
72+
httplib::SSLClient cli("localhost:1234"); // host
73+
74+
// Use your CA bundle
75+
cli.set_ca_cert_path("./ca-bundle.crt");
76+
77+
// Disable cert verification
78+
cli.enable_server_certificate_verification(false);
79+
```
80+
81+
Note: When using SSL, it seems impossible to avoid SIGPIPE in all cases, since on some operating systems, SIGPIPE can only be suppressed on a per-message basis, but there is no way to make the OpenSSL library do so for its internal communications. If your program needs to avoid being terminated on SIGPIPE, the only fully general way might be to set up a signal handler for SIGPIPE to handle or ignore it yourself.
82+
5683
Server
5784
------
5885

@@ -719,32 +746,6 @@ res = cli.Get("/resource/foo", {{"Accept-Encoding", "gzip, deflate, br"}});
719746
res->body; // Compressed data
720747
```
721748
722-
SSL Support
723-
-----------
724-
725-
SSL support is available with `CPPHTTPLIB_OPENSSL_SUPPORT`. `libssl` and `libcrypto` should be linked.
726-
727-
NOTE: cpp-httplib currently supports only version 1.1.1.
728-
729-
```c++
730-
#define CPPHTTPLIB_OPENSSL_SUPPORT
731-
#include "path/to/httplib.h"
732-
733-
// Server
734-
httplib::SSLServer svr("./cert.pem", "./key.pem");
735-
736-
// Client
737-
httplib::Client cli("https://localhost:1234");
738-
739-
// Use your CA bundle
740-
cli.set_ca_cert_path("./ca-bundle.crt");
741-
742-
// Disable cert verification
743-
cli.enable_server_certificate_verification(false);
744-
```
745-
746-
Note: When using SSL, it seems impossible to avoid SIGPIPE in all cases, since on some operating systems, SIGPIPE can only be suppressed on a per-message basis, but there is no way to make the OpenSSL library do so for its internal communications. If your program needs to avoid being terminated on SIGPIPE, the only fully general way might be to set up a signal handler for SIGPIPE to handle or ignore it yourself.
747-
748749
Split httplib.h into .h and .cc
749750
-------------------------------
750751

0 commit comments

Comments
 (0)