{"id":19492787,"url":"https://github.com/oatpp/example-libressl","last_synced_at":"2025-04-25T20:30:36.549Z","repository":{"id":47049486,"uuid":"168182233","full_name":"oatpp/example-libressl","owner":"oatpp","description":"Example project how-to use oatpp-libressl submodule. HTTPS async server.","archived":false,"fork":false,"pushed_at":"2024-04-22T21:28:22.000Z","size":33,"stargazers_count":12,"open_issues_count":3,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T22:52:34.228Z","etag":null,"topics":["async","https-server","libressl","oatpp","tls"],"latest_commit_sha":null,"homepage":"https://oatpp.io/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oatpp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-29T15:54:20.000Z","updated_at":"2024-08-06T06:03:20.000Z","dependencies_parsed_at":"2024-11-07T00:26:33.955Z","dependency_job_id":"008ff0cc-f9f1-4e02-9f1b-fc55c9532f18","html_url":"https://github.com/oatpp/example-libressl","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":"0.030303030303030276","last_synced_commit":"48ebcbeed58242a5277f9080cc287db1b459b498"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Fexample-libressl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Fexample-libressl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Fexample-libressl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oatpp%2Fexample-libressl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oatpp","download_url":"https://codeload.github.com/oatpp/example-libressl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224015658,"owners_count":17241535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","https-server","libressl","oatpp","tls"],"created_at":"2024-11-10T21:23:01.033Z","updated_at":"2024-11-10T21:23:02.949Z","avatar_url":"https://github.com/oatpp.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TLS-LibreSSL Example [![Build Status](https://dev.azure.com/lganzzzo/lganzzzo/_apis/build/status/oatpp.example-libressl?branchName=master)](https://dev.azure.com/lganzzzo/lganzzzo/_build?definitionId=13\u0026branchName=master)\n\nExample project of how-to use [oatpp-libressl](https://github.com/oatpp/oatpp-libressl) module. \n- Serve via HTTPS \n- Make client calls via HTTPS. \n- Using oatpp Async API.\n\nSee more:\n\n- [Oat++ Website](https://oatpp.io/)\n- [Oat++ Github Repository](https://github.com/oatpp/oatpp)\n- [Get Started](https://oatpp.io/docs/start)\n\n## Overview\n\nThis project is using [oatpp](https://github.com/oatpp/oatpp) and [oatpp-libressl](https://github.com/oatpp/oatpp-libressl) modules.\n\n### Project layout\n\n```\n|- CMakeLists.txt                        // projects CMakeLists.txt\n|- src/\n|    |\n|    |- controller/                      // Folder containing Controller where all endpoints are declared\n|    |- client/                          // HTTP client is here. Used in \"proxy\" endpoint /api/get\n|    |- dto/                             // DTOs are declared here\n|    |- AppComponent.hpp                 // Service config\n|    |- App.cpp                          // main() is here\n|    \n|- test/                                 // test folder\n|- utility/install-oatpp-modules.sh      // utility script to install required oatpp-modules.\n|- cert/                                 // folder with test certificates \n```\n\n---\n\n### Build and Run\n\n#### Using CMake\n**Requires** \n\n- LibreSSL installed. You may refer to this sh script - how to install libressl - \n[install-libressl.sh](https://github.com/oatpp/oatpp-libressl/blob/master/utility/install-deps/install-libressl.sh).  \nOr try something like ```$ apk add libressl-dev```\n\n- `oatpp` and `oatpp-libressl` modules installed. You may run `utility/install-oatpp-modules.sh` \nscript to install required oatpp modules.\n\n```\n$ mkdir build \u0026\u0026 cd build\n$ cmake ..\n$ make \n$ ././example-libressl-exe  # - run application.\n```\n\n#### In Docker\n\n```\n$ docker build -t example-libressl .\n$ docker run -p 8443:8443 -t example-libressl\n```\n\n---\n\n### Configure AppComponent\n\nConfigure server secure connection provider\n\n```c++\n\n/**\n *  Create ConnectionProvider component which listens on the port\n */\nOATPP_CREATE_COMPONENT(std::shared_ptr\u003coatpp::network::ServerConnectionProvider\u003e, serverConnectionProvider)([] {\n  /* non_blocking connections should be used with AsyncHttpConnectionHandler for AsyncIO */\n  auto config = oatpp::libressl::Config::createDefaultServerConfig(\"cert/test_key.pem\", \"cert/test_cert.crt\");\n  return oatpp::libressl::server::ConnectionProvider::createShared(config, 8443, true /* true for non_blocking */);\n}());\n\n```\n\nConfigure client secure connection provider\n\n```c++\nOATPP_CREATE_COMPONENT(std::shared_ptr\u003coatpp::network::ClientConnectionProvider\u003e, sslClientConnectionProvider) ([] {\n  auto config = oatpp::libressl::Config::createShared();\n  tls_config_insecure_noverifycert(config-\u003egetTLSConfig());\n  tls_config_insecure_noverifyname(config-\u003egetTLSConfig());\n  return oatpp::libressl::client::ConnectionProvider::createShared(config, \"httpbin.org\", 443);\n}());\n```\n\n### Endpoints\n---\n\"Hello Async\" root endpoint with json response\n```c++\nENDPOINT_ASYNC(\"GET\", \"/\", Root) {\n\n  ENDPOINT_ASYNC_INIT(Root)\n  \n  Action act() override {\n    auto dto = HelloDto::createShared();\n    dto-\u003emessage = \"Hello Async!\";\n    dto-\u003eserver = Header::Value::SERVER;\n    dto-\u003euserAgent = request-\u003egetHeader(Header::USER_AGENT);\n    return _return(controller-\u003ecreateDtoResponse(Status::CODE_200, dto));\n  }\n\n};\n```\n\nresult:\n```\n$ curl -X GET \"https://localhost:8443/\" --insecure\n{\"user-agent\": \"curl\\/7.54.0\", \"message\": \"Hello Async!\", \"server\": \"oatpp\\/0.19.1\"}\n```\n---\nAsync proxy endpoint to ```https://httpbin.org/get```\n\n```c++\nENDPOINT_ASYNC(\"GET\", \"/api/get\", TestApiGet) {\n\n  ENDPOINT_ASYNC_INIT(TestApiGet)\n\n  Action act() override {\n    return controller-\u003emyApiClient-\u003eapiGetAsync().callbackTo(\u0026TestApiGet::onResponse);\n  }\n\n  Action onResponse(const std::shared_ptr\u003cIncomingResponse\u003e\u0026 response){\n    return response-\u003ereadBodyToStringAsync().callbackTo(\u0026TestApiGet::returnResult);\n  }\n\n  Action returnResult(const oatpp::String\u0026 body) {\n    return _return(controller-\u003ecreateResponse(Status::CODE_200, body));\n  }\n\n};\n```\n\nresult:\n```\n$ curl -X GET \"https://localhost:8443/api/get\" --insecure\n{\n  \"args\": {}, \n  \"headers\": {\n    \"Connection\": \"close\", \n    \"Host\": \"httpbin.org\"\n  }, \n  \"origin\": \"176.37.47.230\", \n  \"url\": \"https://httpbin.org/get\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foatpp%2Fexample-libressl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foatpp%2Fexample-libressl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foatpp%2Fexample-libressl/lists"}