Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/envoy/network/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ envoy_cc_library(
":io_handle_interface",
"//include/envoy/buffer:buffer_interface",
"//include/envoy/ssl:connection_interface",
"//include/envoy/ssl:context_config_interface",
],
)

Expand Down
6 changes: 6 additions & 0 deletions include/envoy/network/transport_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "envoy/buffer/buffer.h"
#include "envoy/common/pure.h"
#include "envoy/network/io_handle.h"
#include "envoy/ssl/certificate_validation_context_config.h"
#include "envoy/ssl/connection.h"

#include "absl/types/optional.h"
Expand Down Expand Up @@ -181,6 +182,11 @@ class TransportSocketFactory {
*/
virtual bool implementsSecureTransport() const PURE;

/**
* @return CertificateValidationContextConfig the certificate validation context config.
*/
virtual const Ssl::CertificateValidationContextConfig* certificateValidationContext() const PURE;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a bit of abstraction for this by not leaking Ssl namespace into here, perhaps a Protobuf::Message& config() or abstract class TransportSocketConfig. Ssl::Connection in TransportSocket is due to historical reason and that is to be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like ATLS is not using certificate validation context. How do we tell whether ATLS config is meant for mutual TLS?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean ALTS? If you expose TransportSocket proto does that work?


/**
* @param options for creating the transport socket
* @return Network::TransportSocketPtr a transport socket to be passed to connection.
Expand Down
4 changes: 4 additions & 0 deletions source/common/network/raw_buffer_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,9 @@ RawBufferSocketFactory::createTransportSocket(TransportSocketOptionsSharedPtr) c
}

bool RawBufferSocketFactory::implementsSecureTransport() const { return false; }
const Envoy::Ssl::CertificateValidationContextConfig*
RawBufferSocketFactory::certificateValidationContext() const {
return nullptr;
}
} // namespace Network
} // namespace Envoy
2 changes: 2 additions & 0 deletions source/common/network/raw_buffer_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class RawBufferSocketFactory : public TransportSocketFactory {
// Network::TransportSocketFactory
TransportSocketPtr createTransportSocket(TransportSocketOptionsSharedPtr options) const override;
bool implementsSecureTransport() const override;
const Envoy::Ssl::CertificateValidationContextConfig*
certificateValidationContext() const override;
};

} // namespace Network
Expand Down
4 changes: 4 additions & 0 deletions source/extensions/transport_sockets/alts/tsi_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ TsiSocketFactory::TsiSocketFactory(HandshakerFactory handshaker_factory,
handshake_validator_(std::move(handshake_validator)) {}

bool TsiSocketFactory::implementsSecureTransport() const { return true; }
const Envoy::Ssl::CertificateValidationContextConfig*
TsiSocketFactory::certificateValidationContext() const {
return nullptr;
}

Network::TransportSocketPtr
TsiSocketFactory::createTransportSocket(Network::TransportSocketOptionsSharedPtr) const {
Expand Down
2 changes: 2 additions & 0 deletions source/extensions/transport_sockets/alts/tsi_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class TsiSocketFactory : public Network::TransportSocketFactory {
TsiSocketFactory(HandshakerFactory handshaker_factory, HandshakeValidator handshake_validator);

bool implementsSecureTransport() const override;
const Envoy::Ssl::CertificateValidationContextConfig*
certificateValidationContext() const override;
Network::TransportSocketPtr
createTransportSocket(Network::TransportSocketOptionsSharedPtr options) const override;

Expand Down
5 changes: 5 additions & 0 deletions source/extensions/transport_sockets/tap/tap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ bool TapSocketFactory::implementsSecureTransport() const {
return transport_socket_factory_->implementsSecureTransport();
}

const Envoy::Ssl::CertificateValidationContextConfig*
TapSocketFactory::certificateValidationContext() const {
return transport_socket_factory_->certificateValidationContext();
}

} // namespace Tap
} // namespace TransportSockets
} // namespace Extensions
Expand Down
2 changes: 2 additions & 0 deletions source/extensions/transport_sockets/tap/tap.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class TapSocketFactory : public Network::TransportSocketFactory,
Network::TransportSocketPtr
createTransportSocket(Network::TransportSocketOptionsSharedPtr options) const override;
bool implementsSecureTransport() const override;
const Envoy::Ssl::CertificateValidationContextConfig*
certificateValidationContext() const override;

private:
Network::TransportSocketFactoryPtr transport_socket_factory_;
Expand Down
10 changes: 10 additions & 0 deletions source/extensions/transport_sockets/tls/ssl_socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ Network::TransportSocketPtr ClientSslSocketFactory::createTransportSocket(

bool ClientSslSocketFactory::implementsSecureTransport() const { return true; }

const Envoy::Ssl::CertificateValidationContextConfig*
ClientSslSocketFactory::certificateValidationContext() const {
return config_->certificateValidationContext();
}

void ClientSslSocketFactory::onAddOrUpdateSecret() {
ENVOY_LOG(debug, "Secret is updated.");
{
Expand Down Expand Up @@ -455,6 +460,11 @@ ServerSslSocketFactory::createTransportSocket(Network::TransportSocketOptionsSha

bool ServerSslSocketFactory::implementsSecureTransport() const { return true; }

const Envoy::Ssl::CertificateValidationContextConfig*
ServerSslSocketFactory::certificateValidationContext() const {
return config_->certificateValidationContext();
}

void ServerSslSocketFactory::onAddOrUpdateSecret() {
ENVOY_LOG(debug, "Secret is updated.");
{
Expand Down
4 changes: 4 additions & 0 deletions source/extensions/transport_sockets/tls/ssl_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class ClientSslSocketFactory : public Network::TransportSocketFactory,
Network::TransportSocketPtr
createTransportSocket(Network::TransportSocketOptionsSharedPtr options) const override;
bool implementsSecureTransport() const override;
const Envoy::Ssl::CertificateValidationContextConfig*
certificateValidationContext() const override;

// Secret::SecretCallbacks
void onAddOrUpdateSecret() override;
Expand All @@ -121,6 +123,8 @@ class ServerSslSocketFactory : public Network::TransportSocketFactory,
Network::TransportSocketPtr
createTransportSocket(Network::TransportSocketOptionsSharedPtr options) const override;
bool implementsSecureTransport() const override;
const Envoy::Ssl::CertificateValidationContextConfig*
certificateValidationContext() const override;

// Secret::SecretCallbacks
void onAddOrUpdateSecret() override;
Expand Down
1 change: 1 addition & 0 deletions test/mocks/network/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ class MockTransportSocketFactory : public TransportSocketFactory {
~MockTransportSocketFactory();

MOCK_CONST_METHOD0(implementsSecureTransport, bool());
MOCK_CONST_METHOD0(certificateValidationContext, Ssl::CertificateValidationContextConfig*());
MOCK_CONST_METHOD1(createTransportSocket, TransportSocketPtr(TransportSocketOptionsSharedPtr));
};

Expand Down