/
config.cc
63 lines (50 loc) · 2.53 KB
/
config.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "extensions/transport_sockets/tls/config.h"
#include "envoy/api/v2/auth/cert.pb.h"
#include "envoy/api/v2/auth/cert.pb.validate.h"
#include "common/protobuf/utility.h"
#include "extensions/transport_sockets/tls/context_config_impl.h"
#include "extensions/transport_sockets/tls/ssl_socket.h"
namespace Envoy {
namespace Extensions {
namespace TransportSockets {
namespace Tls {
Network::TransportSocketFactoryPtr UpstreamSslSocketFactory::createTransportSocketFactory(
const Protobuf::Message& message,
Server::Configuration::TransportSocketFactoryContext& context) {
auto client_config = std::make_unique<ClientContextConfigImpl>(
MessageUtil::downcastAndValidate<const envoy::api::v2::auth::UpstreamTlsContext&>(
message, context.messageValidationVisitor()),
context);
return std::make_unique<ClientSslSocketFactory>(
std::move(client_config), context.sslContextManager(), context.statsScope());
}
ProtobufTypes::MessagePtr UpstreamSslSocketFactory::createEmptyConfigProto() {
return std::make_unique<envoy::api::v2::auth::UpstreamTlsContext>();
}
REGISTER_FACTORY(UpstreamSslSocketFactory,
Server::Configuration::UpstreamTransportSocketConfigFactory){"tls"};
Network::TransportSocketFactoryPtr DownstreamSslSocketFactory::createTransportSocketFactory(
const Protobuf::Message& message, Server::Configuration::TransportSocketFactoryContext& context,
const std::vector<std::string>& server_names) {
auto server_config = std::make_unique<ServerContextConfigImpl>(
MessageUtil::downcastAndValidate<const envoy::api::v2::auth::DownstreamTlsContext&>(
message, context.messageValidationVisitor()),
context);
return std::make_unique<ServerSslSocketFactory>(
std::move(server_config), context.sslContextManager(), context.statsScope(), server_names);
}
ProtobufTypes::MessagePtr DownstreamSslSocketFactory::createEmptyConfigProto() {
return std::make_unique<envoy::api::v2::auth::DownstreamTlsContext>();
}
REGISTER_FACTORY(DownstreamSslSocketFactory,
Server::Configuration::DownstreamTransportSocketConfigFactory){"tls"};
Ssl::ContextManagerPtr SslContextManagerFactory::createContextManager(TimeSource& time_source) {
return std::make_unique<ContextManagerImpl>(time_source);
}
static Envoy::Registry::RegisterInternalFactory<SslContextManagerFactory,
Ssl::ContextManagerFactory>
ssl_manager_registered;
} // namespace Tls
} // namespace TransportSockets
} // namespace Extensions
} // namespace Envoy