From 3bce9bfdce707313de4f9cccdc867abd9edf82df Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Fri, 7 Feb 2020 20:00:06 +0100 Subject: [HICN-508] [HICN-509] [HICN-506] Manifest rework Change-Id: I992205148910be008d66b5acb7f6f1365770f9e8 Signed-off-by: Mauro Sardara --- .../src/hicn/transport/http/client_connection.cc | 18 ++++++++++++++++++ .../src/hicn/transport/http/client_connection.h | 7 +++++++ 2 files changed, 25 insertions(+) (limited to 'libtransport/src/hicn/transport/http') diff --git a/libtransport/src/hicn/transport/http/client_connection.cc b/libtransport/src/hicn/transport/http/client_connection.cc index 32269d49d..aa9cb0463 100644 --- a/libtransport/src/hicn/transport/http/client_connection.cc +++ b/libtransport/src/hicn/transport/http/client_connection.cc @@ -16,6 +16,8 @@ #include #include +#include + #define DEFAULT_BETA 0.99 #define DEFAULT_GAMMA 0.07 @@ -38,6 +40,12 @@ HTTPClientConnection::HTTPClientConnection() std::placeholders::_2)); consumer_.setSocketOption(ConsumerCallbacksOptions::READ_CALLBACK, this); + consumer_.setSocketOption( + ConsumerCallbacksOptions::VERIFICATION_FAILED, + (ConsumerContentObjectVerificationFailedCallback)std::bind( + &HTTPClientConnection::onSignatureVerificationFailed, this, + std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + consumer_.setSocketOption(GeneralTransportOptions::VERIFY_SIGNATURE, false); consumer_.connect(); std::shared_ptr portal; @@ -87,6 +95,10 @@ HTTPClientConnection::RC HTTPClientConnection::sendRequest( return return_code_; } +void HTTPClientConnection::verifyPacketSignature(bool verify) { + consumer_.setSocketOption(GeneralTransportOptions::VERIFY_SIGNATURE, verify); +} + void HTTPClientConnection::sendRequestGetReply( const HTTPRequest &request, std::shared_ptr &response, std::string &ipv6_first_word) { @@ -186,6 +198,12 @@ HTTPClientConnection &HTTPClientConnection::setCertificate( return *this; } +VerificationPolicy HTTPClientConnection::onSignatureVerificationFailed( + ConsumerSocket &consumer, const core::ContentObject &content_object, + std::error_code reason) { + return VerificationPolicy::ACCEPT_PACKET; +} + // Read buffer management void HTTPClientConnection::readBufferAvailable( std::unique_ptr &&buffer) noexcept { diff --git a/libtransport/src/hicn/transport/http/client_connection.h b/libtransport/src/hicn/transport/http/client_connection.h index 5bcf9c4c7..e001653ab 100644 --- a/libtransport/src/hicn/transport/http/client_connection.h +++ b/libtransport/src/hicn/transport/http/client_connection.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -68,6 +69,8 @@ class HTTPClientConnection : public ConsumerSocket::ReadCallback { HTTPClientConnection &setCertificate(const std::string &cert_path); + void verifyPacketSignature(bool verify); + private: void sendRequestGetReply(const HTTPRequest &request, std::shared_ptr &response, @@ -80,6 +83,10 @@ class HTTPClientConnection : public ConsumerSocket::ReadCallback { const core::Interest &interest, std::string &payload); + VerificationPolicy onSignatureVerificationFailed( + ConsumerSocket &consumer, const core::ContentObject &content_object, + std::error_code reason); + // Read callback bool isBufferMovable() noexcept override { return true; } void getReadBuffer(uint8_t **application_buffer, -- cgit 1.2.3-korg