21 const ACMEClientConfig& cfg)
27 cfg.alternative_names,
29 cfg.terms_of_service_agreed,
49 virtual bool ready(
const std::string& token)
override
60 virtual void remove(
const std::string& token)
override
77 std::shared_ptr<RPCMap>
rpc_map,
80 std::shared_ptr<ccf::kv::Store>
store,
82 std::shared_ptr<ACMEChallengeHandler> challenge_handler_ =
nullptr) :
101 std::shared_ptr<ccf::crypto::KeyPair> new_account_key_pair)
override
108 std::shared_ptr<ccf::kv::Store> tables,
109 std::unique_ptr<NetworkIdentity>& identity)
111 auto now = std::chrono::system_clock::now();
113 auto tx = tables->create_read_only_tx();
119 double rem_pct = v->remaining_percentage(now);
121 "ACME: remaining certificate validity for '{}': {}%, {} seconds",
124 v->remaining_seconds(now));
125 renew = rem_pct < 0.33;
135 std::shared_ptr<ACMEChallengeHandler> h)
146 std::shared_ptr<ccf::kv::Store>
store;
161 const ::http::URL& url,
168 auto ca_cert = std::make_shared<::tls::Cert>(ca);
177 std::vector<uint8_t>&& data) {
178 return callback(status, std::move(headers), std::move(data));
180 client->send_request(std::move(req));
187 const std::shared_ptr<ACMEChallengeHandler>
handler,
188 const std::string&
token) :
194 std::shared_ptr<ACMEChallengeHandler>
handler;
199 const std::string& token,
const std::string& response)
override
203 throw std::runtime_error(
"No ACME challenge handler");
210 auto msg = std::make_unique<Tmsg<ACMEClientMsg>>(
211 [](std::unique_ptr<Tmsg<ACMEClientMsg>> msg) {
212 auto&
client = msg->data.client;
213 auto& handler = msg->data.handler;
214 auto& token = msg->data.token;
215 if (handler->ready(token))
217 client.start_challenge(token);
221 ThreadMessaging::instance().add_task_after(
222 std::move(msg), std::chrono::seconds(1));
229 ThreadMessaging::instance().add_task_after(
230 std::move(msg), std::chrono::seconds(1));
245 auto tx =
store->create_tx();
Definition acme_client.h:64
void get_certificate(std::shared_ptr< ccf::crypto::KeyPair > service_key_, bool override_time=false)
Definition acme_client.h:76
virtual void set_account_key(std::shared_ptr< ccf::crypto::KeyPair > new_account_key_pair)
Definition acme_client.h:151
std::shared_ptr< ccf::crypto::KeyPair > account_key_pair
Definition acme_client.h:368
std::string make_challenge_response() const
Definition acme_client.h:875
ClientConfig config
Definition acme_client.h:366
Client(const ClientConfig &config, std::shared_ptr< ccf::crypto::KeyPair > account_key_pair=nullptr)
Definition acme_client.h:66
Definition acme_client_config.h:62
std::map< std::string, std::string > token_responses
Definition acme_client_config.h:64
Definition ccf_acme_client.h:41
virtual ~DefaultChallengeHandler()=default
std::shared_ptr< ACMERpcFrontend > challenge_frontend
Definition ccf_acme_client.h:70
DefaultChallengeHandler(std::shared_ptr< ACMERpcFrontend > challenge_frontend)
Definition ccf_acme_client.h:43
virtual void remove(const std::string &token) override
Definition ccf_acme_client.h:60
virtual bool ready(const std::string &token) override
Definition ccf_acme_client.h:49
Definition ccf_acme_client.h:37
std::shared_ptr< ccf::kv::Store > store
Definition ccf_acme_client.h:146
std::shared_ptr< ACMEChallengeHandler > challenge_handler
Definition ccf_acme_client.h:147
virtual void on_challenge(const std::string &token, const std::string &response) override
Definition ccf_acme_client.h:198
virtual void check_expiry(std::shared_ptr< ccf::kv::Store > tables, std::unique_ptr< NetworkIdentity > &identity)
Definition ccf_acme_client.h:107
virtual ~ACMEClient()
Definition ccf_acme_client.h:98
virtual void on_challenge_finished(const std::string &token) override
Definition ccf_acme_client.h:233
virtual void on_http_request(const ::http::URL &url, ::http::Request &&req, std::function< bool(ccf::http_status status, http::HeaderMap &&, std::vector< uint8_t > &&)> callback) override
Definition ccf_acme_client.h:160
std::string config_name
Definition ccf_acme_client.h:142
std::shared_ptr< ACMERpcFrontend > challenge_frontend
Definition ccf_acme_client.h:145
virtual void on_certificate(const std::string &certificate) override
Definition ccf_acme_client.h:241
virtual void set_account_key(std::shared_ptr< ccf::crypto::KeyPair > new_account_key_pair) override
Definition ccf_acme_client.h:100
ACMEClient(const std::string &config_name, const ACMEClientConfig &config, std::shared_ptr< RPCMap > rpc_map, std::shared_ptr< RPCSessions > rpc_sessions, std::shared_ptr< ACMERpcFrontend > challenge_frontend, std::shared_ptr< ccf::kv::Store > store, std::shared_ptr< ccf::crypto::KeyPair > account_key_pair=nullptr, std::shared_ptr< ACMEChallengeHandler > challenge_handler_=nullptr)
Definition ccf_acme_client.h:74
std::shared_ptr< RPCMap > rpc_map
Definition ccf_acme_client.h:143
void install_wildcard_response()
Definition ccf_acme_client.h:149
std::shared_ptr< RPCSessions > rpc_sessions
Definition ccf_acme_client.h:144
virtual void install_custom_challenge_handler(std::shared_ptr< ACMEChallengeHandler > h)
Definition ccf_acme_client.h:134
Definition http_builder.h:118
#define LOG_TRACE_FMT
Definition logger.h:356
Definition acme_client.h:30
VerifierPtr make_verifier(const std::vector< uint8_t > &cert)
Definition verifier.cpp:18
std::map< std::string, std::string, std::less<> > HeaderMap
Definition http_header_map.h:10
Definition app_interface.h:14
llhttp_status http_status
Definition http_status.h:9
Definition perf_client.h:12
Definition thread_messaging.h:14
Definition acme_client.h:32
std::vector< std::string > ca_certs
Definition acme_client.h:35
Definition acme_client_config.h:14
Definition ccf_acme_client.h:184
std::string token
Definition ccf_acme_client.h:195
std::shared_ptr< ACMEChallengeHandler > handler
Definition ccf_acme_client.h:194
ACMEClientMsg(ACMEClient &client, const std::shared_ptr< ACMEChallengeHandler > handler, const std::string &token)
Definition ccf_acme_client.h:185
ACMEClient & client
Definition ccf_acme_client.h:193