How to use OpenSSL in POCO C++ library correctly

前端 未结 2 1649
耶瑟儿~
耶瑟儿~ 2020-12-13 20:58

According to the Specification in POCO assistant:

Initialize the NetSSL library, as well as the underlying OpenSSL libraries, by calling Poco::Crypt

2条回答
  •  青春惊慌失措
    2020-12-13 21:34

    Let's take Net/samples/httpget as an example, let's copy httpget/ as a new httpsget directory:

    1. open Makefile, add "PocoNetSSL" to target_libs
    2. replace 'HTTPClientSession' with 'HTTPSClientSession'
    3. you need to create Poco::Net::Context for SSL use
    4. replace 'HTTPClientSession session(uri.getHost(), uri.getPort());' with following two lines:
    const Context::Ptr context = new Context(Context::CLIENT_USE, "", "", "", Context::VERIFY_NONE, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
    HTTPSClientSession session(uri.getHost(), uri.getPort(), context);

    Summary:

    1. add PocoNetSSL as a lib_depends
    2. use Poco::Net::Context with HTTPSClientSession

提交回复
热议问题