Line data Source code
1 : #pragma once 2 : 3 : #include <cstdint> 4 : #include <functional> 5 : #include <list> 6 : 7 : #include "envoy/common/time.h" 8 : #include "envoy/ssl/context_manager.h" 9 : #include "envoy/ssl/private_key/private_key.h" 10 : #include "envoy/stats/scope.h" 11 : 12 : #include "source/extensions/transport_sockets/tls/private_key/private_key_manager_impl.h" 13 : 14 : namespace Envoy { 15 : namespace Extensions { 16 : namespace TransportSockets { 17 : namespace Tls { 18 : 19 : /** 20 : * The SSL context manager has the following threading model: 21 : * Contexts can be allocated via any thread (through in practice they are only allocated on the main 22 : * thread). They can be released from any thread (and in practice are since cluster information can 23 : * be released from any thread). Context allocation/free is a very uncommon thing so we just do a 24 : * global lock to protect it all. 25 : */ 26 : class ContextManagerImpl final : public Envoy::Ssl::ContextManager { 27 : public: 28 : explicit ContextManagerImpl(TimeSource& time_source); 29 229 : ~ContextManagerImpl() override = default; 30 : 31 : // Ssl::ContextManager 32 : Ssl::ClientContextSharedPtr 33 : createSslClientContext(Stats::Scope& scope, 34 : const Envoy::Ssl::ClientContextConfig& config) override; 35 : Ssl::ServerContextSharedPtr 36 : createSslServerContext(Stats::Scope& scope, const Envoy::Ssl::ServerContextConfig& config, 37 : const std::vector<std::string>& server_names) override; 38 : absl::optional<uint32_t> daysUntilFirstCertExpires() const override; 39 : absl::optional<uint64_t> secondsUntilFirstOcspResponseExpires() const override; 40 : void iterateContexts(std::function<void(const Envoy::Ssl::Context&)> callback) override; 41 0 : Ssl::PrivateKeyMethodManager& privateKeyMethodManager() override { 42 0 : return private_key_method_manager_; 43 0 : }; 44 : void removeContext(const Envoy::Ssl::ContextSharedPtr& old_context) override; 45 : 46 : private: 47 : TimeSource& time_source_; 48 : absl::flat_hash_set<Envoy::Ssl::ContextSharedPtr> contexts_; 49 : PrivateKeyMethodManagerImpl private_key_method_manager_{}; 50 : }; 51 : 52 : } // namespace Tls 53 : } // namespace TransportSockets 54 : } // namespace Extensions 55 : } // namespace Envoy