diff options
author | jacobkeeler <jacob.keeler@livioradio.com> | 2019-03-05 21:31:13 -0500 |
---|---|---|
committer | jacobkeeler <jacob.keeler@livioradio.com> | 2019-03-05 21:31:13 -0500 |
commit | 799220d37076e9da4900e97fe634ee5343a095ae (patch) | |
tree | 23e3cf36a4564189ed927bb7eb0a1e63764321cb | |
parent | 405c5e34a99c96a4d5b64c53e6fe4ee015273d44 (diff) | |
download | sdl_core-feature/secure_websocket_connection.tar.gz |
Fix issues after mergefeature/secure_websocket_connection
4 files changed, 38 insertions, 31 deletions
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index fd30c4ee03..36309fa2f9 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -905,10 +905,16 @@ void ApplicationManagerImpl::DisconnectCloudApp(ApplicationSharedPtr app) { // Delete the cloud device connection_handler().RemoveCloudAppDevice(app->device()); + transport_manager::transport_adapter::CloudAppProperties properties{ + endpoint, + certificate, + enabled, + auth_token, + cloud_transport_type, + hybrid_app_preference}; // Create device in pending state LOG4CXX_DEBUG(logger_, "Re-adding the cloud app device"); - connection_handler().AddCloudAppDevice( - policy_app_id, endpoint, cloud_transport_type); + connection_handler().AddCloudAppDevice(policy_app_id, properties); } void ApplicationManagerImpl::RefreshCloudAppInformation() { diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index ed8880d066..7e93e04047 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -1354,7 +1354,8 @@ void ConnectionHandlerImpl::AddCloudAppDevice( const transport_manager::transport_adapter::CloudAppProperties& cloud_properties) { cloud_app_id_map_lock_.Acquire(); - cloud_app_id_map_[policy_app_id] = std::make_pair(endpoint, 0); + cloud_app_id_map_[policy_app_id] = + std::make_pair(cloud_properties.endpoint, 0); cloud_app_id_map_lock_.Release(); transport_manager_.AddCloudDevice(cloud_properties); } diff --git a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h index cb7731bcce..aa608312a0 100644 --- a/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h +++ b/src/components/transport_manager/include/transport_manager/cloud/websocket_client_connection.h @@ -142,8 +142,8 @@ class WebsocketClientConnection boost::beast::flat_buffer buffer_; std::string host_; std::string text_; - std::shared_ptr<WS> ws_; - std::shared_ptr<WSS> wss_; + WS ws_; + WSS wss_; std::atomic_bool shutdown_; diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index dd25c74de6..5c9553a970 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -49,6 +49,8 @@ WebsocketClientConnection::WebsocketClientConnection( : controller_(controller) , ctx_(ssl::context::sslv23_client) , resolver_(ioc_) + , ws_(ioc_) + , wss_(ioc_, ctx_) , shutdown_(false) , thread_delegate_(new LoopThreadDelegate(&message_queue_, this)) , write_thread_(threads::CreateThread("WS Async Send", thread_delegate_)) @@ -69,7 +71,7 @@ void WebsocketClientConnection::AddCertificateAuthority( return; } - wss_->next_layer().set_verify_mode(ssl::verify_peer); + wss_.next_layer().set_verify_mode(ssl::verify_peer); } TransportAdapter::Error WebsocketClientConnection::Start() { @@ -105,12 +107,10 @@ TransportAdapter::Error WebsocketClientConnection::Start() { // Make Connection to host IP Address over TCP if (cloud_properties.cloud_transport_type == "WSS") { - wss_ = std::make_shared<WSS>(ioc_, ctx_); boost::asio::connect( - wss_->next_layer().next_layer(), results.begin(), results.end(), ec); + wss_.next_layer().next_layer(), results.begin(), results.end(), ec); } else { - ws_ = std::make_shared<WS>(ioc_); - boost::asio::connect(ws_->next_layer(), results.begin(), results.end(), ec); + boost::asio::connect(ws_.next_layer(), results.begin(), results.end(), ec); } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -134,7 +134,7 @@ TransportAdapter::Error WebsocketClientConnection::Start() { } // Perform SSL Handshake - wss_->next_layer().handshake(ssl::stream_base::client, ec); + wss_.next_layer().handshake(ssl::stream_base::client, ec); if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -149,9 +149,9 @@ TransportAdapter::Error WebsocketClientConnection::Start() { // Perform websocket handshake if (cloud_properties.cloud_transport_type == "WSS") { - wss_->handshake(host, "/", ec); + wss_.handshake(host, "/", ec); } else { - ws_->handshake(host, "/", ec); + ws_.handshake(host, "/", ec); } if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); @@ -164,26 +164,26 @@ TransportAdapter::Error WebsocketClientConnection::Start() { // Set the binary message write option if (cloud_properties.cloud_transport_type == "WSS") { - wss_->binary(true); + wss_.binary(true); } else { - ws_->binary(true); + ws_.binary(true); } write_thread_->start(threads::ThreadOptions()); controller_->ConnectDone(device_uid_, app_handle_); // Start async read if (cloud_properties.cloud_transport_type == "WSS") { - wss_->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); - } else { - ws_->async_read(buffer_, + wss_.async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, this, std::placeholders::_1, std::placeholders::_2)); + } else { + ws_.async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); } boost::asio::post(io_pool_, [&]() { ioc_.run(); }); @@ -206,17 +206,17 @@ void WebsocketClientConnection::Recv(boost::system::error_code ec) { return; } if (cloud_properties.cloud_transport_type == "WSS") { - wss_->async_read(buffer_, - std::bind(&WebsocketClientConnection::OnRead, - this, - std::placeholders::_1, - std::placeholders::_2)); - } else { - ws_->async_read(buffer_, + wss_.async_read(buffer_, std::bind(&WebsocketClientConnection::OnRead, this, std::placeholders::_1, std::placeholders::_2)); + } else { + ws_.async_read(buffer_, + std::bind(&WebsocketClientConnection::OnRead, + this, + std::placeholders::_1, + std::placeholders::_2)); } } @@ -301,10 +301,10 @@ void WebsocketClientConnection::LoopThreadDelegate::DrainQueue() { if (!shutdown_) { boost::system::error_code ec; if (handler_.cloud_properties.cloud_transport_type == "WSS") { - handler_.wss_->write( + handler_.wss_.write( boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); } else { - handler_.ws_->write( + handler_.ws_.write( boost::asio::buffer(message_ptr->data(), message_ptr->data_size())); } if (ec) { |