oatpp / oatpp-openssl

OpenSSL adaptor for Oat++ applications

Home Page:https://oatpp.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't connect to web server via this module

hhashoww opened this issue · comments

Hi,

I'd like to create a web server with https, so I use this module as the following step:

Step1: use oatpp-openssl library to create a connection provider component in AppComponent.cpp:

  OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::openssl::server::ConnectionProvider>, serverConnectionProvider)
  ([] {
    const char* serverCertificateFile = "./cert/self-signed/host.crt";
    const char* serverPrivateKeyFile = "./cert/self-signed/host.key";

    auto config = oatpp::openssl::Config::createDefaultServerConfigShared(serverCertificateFile, serverPrivateKeyFile);
    auto connectionProvider = oatpp::openssl::server::ConnectionProvider::createShared(config, {"0.0.0.0", 8443});
    return connectionProvider;
  }());

Step2: create server in the App.cpp

  /* Get connection handler component */
  OATPP_COMPONENT(std::shared_ptr<oatpp::network::ConnectionHandler>, connectionHandler, "https");

  // Get connection provider component (https)
  OATPP_COMPONENT(std::shared_ptr<oatpp::openssl::server::ConnectionProvider>, connectionProvider);

  // Create server which takes provided TCP connections and passes them to HTTPS connection handler
  oatpp::network::Server server(connectionProvider, connectionHandler);

After that, I can connect to the server at localhost, but I cannot use the other PC to connect this server via the host IP

Is there any suggestion?

BTW, If I use HTTP to create the connection provider, It works

  OATPP_CREATE_COMPONENT(std::shared_ptr<oatpp::network::ServerConnectionProvider>, serverConnectionProvider)
  ([] {
     return oatpp::network::tcp::server::ConnectionProvider::createShared(
         {"0.0.0.0", 8080, oatpp::network::Address::IP_4});
  }());

Sorry, I find that is the firewall issue in my environment