Skip to content

Commit

Permalink
Merge pull request #5 from oatpp/fix_missing_host_name
Browse files Browse the repository at this point in the history
Fix missing host-name
  • Loading branch information
lganzzzo authored Jan 21, 2021
2 parents 68d31ed + 7bff23b commit b45f755
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/oatpp-openssl/client/ConnectionProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ std::shared_ptr<ConnectionProvider> ConnectionProvider::createShared(const std::

std::shared_ptr<data::stream::IOStream> ConnectionProvider::get(){

// oatpp::String host;
// auto hostName = m_streamProvider->getProperty(oatpp::network::ConnectionProvider::PROPERTY_HOST);
// if(hostName) {
// host = hostName.toString();
// }
oatpp::String host;
auto hostName = m_streamProvider->getProperty(oatpp::network::ConnectionProvider::PROPERTY_HOST);
if(hostName) {
host = hostName.toString();
}

auto transportStream = m_streamProvider->get();

Expand All @@ -98,6 +98,7 @@ std::shared_ptr<data::stream::IOStream> ConnectionProvider::get(){
auto ssl = SSL_new(m_ctx);
SSL_set_mode(ssl, SSL_MODE_ENABLE_PARTIAL_WRITE);
SSL_set_connect_state(ssl);
SSL_set_tlsext_host_name(ssl, host->c_str());

auto sslConnection = std::make_shared<Connection>(ssl, transportStream);

Expand Down Expand Up @@ -142,15 +143,16 @@ oatpp::async::CoroutineStarterForResult<const std::shared_ptr<data::stream::IOSt

Action secureConnection() {

// oatpp::String host;
// auto hostName = m_streamProvider->getProperty(oatpp::network::ConnectionProvider::PROPERTY_HOST);
// if(hostName) {
// host = hostName.toString();
// }
oatpp::String host;
auto hostName = m_streamProvider->getProperty(oatpp::network::ConnectionProvider::PROPERTY_HOST);
if(hostName) {
host = hostName.toString();
}

auto ssl = SSL_new(m_ctx);
SSL_set_mode(ssl, SSL_MODE_ENABLE_PARTIAL_WRITE);
SSL_set_connect_state(ssl);
SSL_set_tlsext_host_name(ssl, host->c_str());

m_connection = std::make_shared<Connection>(ssl, m_stream);

Expand Down

0 comments on commit b45f755

Please sign in to comment.