1. 30 Jan, 2019 2 commits
  2. 28 Jan, 2019 2 commits
    • Dennis Jenkins's avatar
      Merge pull request #226 from denkeep/work/louis/pistache_upstream_pr · 6385be12
      Dennis Jenkins authored
      [ENDPOINT] NEW: Now can use SSL encryption on HTTP endpoint
      6385be12
    • Louis Solofrizzo's avatar
      [ENDPOINT] NEW: Now can use SSL encryption on HTTP endpoint: · dfb57706
      Louis Solofrizzo authored
      Introduction
      ------------
      
      This patch introduces full SSL support for the pistache endpoint.  The
      purpose of this patch is to be able to use SSL encryption without a SSL
      proxy, which is pretty useful for embedded development.  It has been
      tested locally with simple SSL support and certificate connection, my
      example file is below.
      
      Features
      --------
      
      First of all, in order to enable SSL support in the library, one has to
      compile with PISTACHE_USE_SSL option ON. One can then configure the
      endpoint to accept / use SSL connections only:
      
          Http::Endpoint server(addr);
          server.useSSL("./server.crt", "./cert/server.key");
      
      With that done, all the connections to the server shall now be in HTTPS.
      One can also enable certificate authentication against the server:
      
          server.useSSLAuth("./rootCA.crt");
      
      The server will now only accept client connection with a certificate
      signed with the Certificate Authority passed in the example above.
      
      How to use it
      -------------
      
      Test file:
      
          #include <pistache/endpoint.h>
      
          using namespace Pistache;
      
          struct HelloHandler : public Http::Handler {
              HTTP_PROTOTYPE(HelloHandler)
      
              void onRequest(const Http::Request& request, Http::ResponseWriter writer) {
                  writer.send(Http::Code::Ok, "Hello, World!");
              }
          };
      
          int main(void) {
              Pistache::Address   addr;
              auto opts = Http::Endpoint::options().threads(1);
      
              addr = Pistache::Address(Pistache::Ipv4::any(), Pistache::Port(9080));
      
              Http::Endpoint server(addr);
              server.init(opts);
              server.setHandler(std::make_shared<HelloHandler>());
              server.useSSL("./cert/server.crt", "./cert/server.key");
      
              server.serve();
              return 0;
          }
      
      Compiled with:
      
          g++ main.cpp -L../pistache/build/src/ -lpistache -I../pistache/include/ -o server -lpthread -lssl -lcrypto
      
      In order to generate a Certificate Authority and server / client
      certificate and key, please refer to this gist[1].
      
      Tests
      -----
      
      I've added unit tests to this commit, they should automatically compile
      / launch with PISTACHE_SSL=ON.
      
      Pull Request  : https://github.com/oktal/pistache/pull/226
      Signed-off-by : Louis Solofrizzo <louis@ne02ptzero.me> (Using Scaleway signing Key)
      Reviewed-by   : mauriciovasquezbernal <mauricio.vasquez@polito.it>
      Reviewed-by   : snilga
      Commited-by   : dennisjenkins75 <dennis.jenkins.75@gmail.com>
      Origin        : denkeep/pistache
      
      [1] https://gist.github.com/fntlnz/cf14feb5a46b2eda428e000157447309
      
       _________________________________________
      / A man may be so much of everything that \
      | he is nothing of anything. -- Samuel    |
      \ Johnson                                 /
       -----------------------------------------
              \   ^__^
               \  (oo)\_______
                  (__)\       )\/\
                      ||----w |
                      ||     ||
      dfb57706
  3. 26 Jan, 2019 5 commits
  4. 25 Jan, 2019 3 commits
  5. 23 Jan, 2019 2 commits
  6. 22 Jan, 2019 6 commits
  7. 20 Jan, 2019 1 commit
  8. 19 Jan, 2019 3 commits
  9. 18 Jan, 2019 2 commits
  10. 16 Jan, 2019 3 commits
  11. 08 Jan, 2019 1 commit
  12. 07 Jan, 2019 1 commit
  13. 04 Jan, 2019 2 commits
  14. 02 Jan, 2019 1 commit
  15. 01 Jan, 2019 6 commits