CCF
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
ACME::Client Class Referenceabstract

#include <acme_client.h>

Inherited by ccf::ACMEClient.

Classes

struct  Challenge
 
struct  ChallengeWaitMsg
 
struct  FinalizationWaitMsg
 
class  JWK
 
class  JWS
 
struct  Order
 

Public Member Functions

 Client (const ClientConfig &config, std::shared_ptr< ccf::crypto::KeyPair > account_key_pair=nullptr)
 
virtual ~Client ()
 
void get_certificate (std::shared_ptr< ccf::crypto::KeyPair > service_key_, bool override_time=false)
 
void start_challenge (const std::string &token)
 
virtual void set_account_key (std::shared_ptr< ccf::crypto::KeyPair > new_account_key_pair)
 
bool has_active_orders () const
 

Protected Types

enum  OrderStatus { ACTIVE , FINISHED , FAILED }
 

Protected Member Functions

virtual void on_challenge (const std::string &token, const std::string &response)=0
 
virtual void on_challenge_finished (const std::string &token)=0
 
virtual void on_certificate (const std::string &certificate)=0
 
virtual void on_http_request (const http::URL &url, http::Request &&req, std::function< bool(ccf::http_status status, ccf::http::HeaderMap &&, std::vector< uint8_t > &&)> callback)=0
 
void make_request (llhttp_method method, const http::URL &url, const std::vector< uint8_t > &body, ccf::http_status expected_status, std::function< bool(const ccf::http::HeaderMap &, const std::vector< uint8_t > &)> ok_callback)
 
void make_json_request (llhttp_method method, const http::URL &url, const std::vector< uint8_t > &body, ccf::http_status expected_status, std::function< void(const ccf::http::HeaderMap &headers, const nlohmann::json &)> ok_callback)
 
void post_as_get (const std::string &account_url, const std::string &resource_url, std::function< bool(const ccf::http::HeaderMap &, const std::vector< uint8_t > &)> ok_callback)
 
void post_as_get_json (const std::string &account_url, const std::string &resource_url, std::function< bool(const ccf::http::HeaderMap &, const nlohmann::json &)> ok_callback, bool empty_payload=false)
 
Orderget_order (const std::string &order_url)
 
void remove_order (const std::string &order_url)
 
nlohmann::json mk_kid_header (const std::string &account_url, const std::string &nonce, const std::string &resource_url)
 
void request_directory ()
 
void request_new_nonce (std::function< void()> ok_callback)
 
void request_new_account ()
 
void authorize_next_challenge (const std::string &order_url)
 
void request_new_order (const std::string &account_url)
 
void request_authorization (Order &order, const std::string &authz_url)
 
std::string make_challenge_response () const
 
void add_challenge (Order &order, const std::string &token, const std::string &authorization_url, const std::string &challenge_url)
 
std::unique_ptr< threading::Tmsg< ChallengeWaitMsg > > schedule_check_challenge (const std::string &order_url, Challenge &challenge)
 
bool check_challenge (const std::string &order_url, const Challenge &challenge)
 
void finish_challenge (const std::string &order_url, const std::string &challenge_token)
 
bool check_finalization (const std::string &order_url)
 
std::unique_ptr< threading::Tmsg< FinalizationWaitMsg > > schedule_check_finalization (const std::string &order_url)
 
virtual std::vector< uint8_t > get_service_csr ()
 
void request_finalization (const std::string &order_url)
 
void request_certificate (const std::string &order_url)
 

Static Protected Member Functions

static http::URL with_default_port (const std::string &url, const std::string &default_port="443")
 
static std::vector< uint8_t > s2v (const std::string &s)
 
static std::vector< uint8_t > json_to_bytes (const nlohmann::json &j)
 
static std::string json_to_b64url (const nlohmann::json &j, bool with_padding=true)
 
static void convert_signature_to_ieee_p1363 (std::vector< uint8_t > &sig, const ccf::crypto::KeyPair &signer)
 
static std::optional< std::string > get_header_value (const ccf::http::HeaderMap &headers, const std::string &name)
 
static void expect (const nlohmann::json &j, const std::string &key)
 
static void expect_string (const nlohmann::json &j, const std::string &key, const std::string &value)
 
static std::pair< std::string, std::string > get_crv_alg (const std::shared_ptr< ccf::crypto::KeyPair > &key_pair)
 

Protected Attributes

ClientConfig config
 
std::shared_ptr< ccf::crypto::KeyPairservice_key
 
std::shared_ptr< ccf::crypto::KeyPairaccount_key_pair
 
nlohmann::json directory
 
nlohmann::json account
 
std::list< std::string > nonces
 
ccf::pal::Mutex req_lock
 
ccf::pal::Mutex orders_lock
 
std::optional< std::chrono::system_clock::time_point > last_request
 
size_t num_failed_attempts = 0
 
std::list< Orderactive_orders
 

Member Enumeration Documentation

◆ OrderStatus

enum ACME::Client::OrderStatus
protected
Enumerator
ACTIVE 
FINISHED 
FAILED 

Constructor & Destructor Documentation

◆ Client()

ACME::Client::Client ( const ClientConfig config,
std::shared_ptr< ccf::crypto::KeyPair account_key_pair = nullptr 
)
inline

◆ ~Client()

virtual ACME::Client::~Client ( )
inlinevirtual

Member Function Documentation

◆ add_challenge()

void ACME::Client::add_challenge ( Order order,
const std::string &  token,
const std::string &  authorization_url,
const std::string &  challenge_url 
)
inlineprotected

◆ authorize_next_challenge()

void ACME::Client::authorize_next_challenge ( const std::string &  order_url)
inlineprotected

◆ check_challenge()

bool ACME::Client::check_challenge ( const std::string &  order_url,
const Challenge challenge 
)
inlineprotected

◆ check_finalization()

bool ACME::Client::check_finalization ( const std::string &  order_url)
inlineprotected

◆ convert_signature_to_ieee_p1363()

static void ACME::Client::convert_signature_to_ieee_p1363 ( std::vector< uint8_t > &  sig,
const ccf::crypto::KeyPair signer 
)
inlinestaticprotected

◆ expect()

static void ACME::Client::expect ( const nlohmann::json &  j,
const std::string &  key 
)
inlinestaticprotected

◆ expect_string()

static void ACME::Client::expect_string ( const nlohmann::json &  j,
const std::string &  key,
const std::string &  value 
)
inlinestaticprotected

◆ finish_challenge()

void ACME::Client::finish_challenge ( const std::string &  order_url,
const std::string &  challenge_token 
)
inlineprotected

◆ get_certificate()

void ACME::Client::get_certificate ( std::shared_ptr< ccf::crypto::KeyPair service_key_,
bool  override_time = false 
)
inline

◆ get_crv_alg()

static std::pair< std::string, std::string > ACME::Client::get_crv_alg ( const std::shared_ptr< ccf::crypto::KeyPair > &  key_pair)
inlinestaticprotected

◆ get_header_value()

static std::optional< std::string > ACME::Client::get_header_value ( const ccf::http::HeaderMap headers,
const std::string &  name 
)
inlinestaticprotected

◆ get_order()

Order * ACME::Client::get_order ( const std::string &  order_url)
inlineprotected

◆ get_service_csr()

virtual std::vector< uint8_t > ACME::Client::get_service_csr ( )
inlineprotectedvirtual

◆ has_active_orders()

bool ACME::Client::has_active_orders ( ) const
inline

◆ json_to_b64url()

static std::string ACME::Client::json_to_b64url ( const nlohmann::json &  j,
bool  with_padding = true 
)
inlinestaticprotected

◆ json_to_bytes()

static std::vector< uint8_t > ACME::Client::json_to_bytes ( const nlohmann::json &  j)
inlinestaticprotected

◆ make_challenge_response()

std::string ACME::Client::make_challenge_response ( ) const
inlineprotected

◆ make_json_request()

void ACME::Client::make_json_request ( llhttp_method  method,
const http::URL url,
const std::vector< uint8_t > &  body,
ccf::http_status  expected_status,
std::function< void(const ccf::http::HeaderMap &headers, const nlohmann::json &)>  ok_callback 
)
inlineprotected

◆ make_request()

void ACME::Client::make_request ( llhttp_method  method,
const http::URL url,
const std::vector< uint8_t > &  body,
ccf::http_status  expected_status,
std::function< bool(const ccf::http::HeaderMap &, const std::vector< uint8_t > &)>  ok_callback 
)
inlineprotected

◆ mk_kid_header()

nlohmann::json ACME::Client::mk_kid_header ( const std::string &  account_url,
const std::string &  nonce,
const std::string &  resource_url 
)
inlineprotected

◆ on_certificate()

virtual void ACME::Client::on_certificate ( const std::string &  certificate)
protectedpure virtual

Implemented in ccf::ACMEClient.

◆ on_challenge()

virtual void ACME::Client::on_challenge ( const std::string &  token,
const std::string &  response 
)
protectedpure virtual

Implemented in ccf::ACMEClient.

◆ on_challenge_finished()

virtual void ACME::Client::on_challenge_finished ( const std::string &  token)
protectedpure virtual

Implemented in ccf::ACMEClient.

◆ on_http_request()

virtual void ACME::Client::on_http_request ( const http::URL url,
http::Request &&  req,
std::function< bool(ccf::http_status status, ccf::http::HeaderMap &&, std::vector< uint8_t > &&)>  callback 
)
protectedpure virtual

◆ post_as_get()

void ACME::Client::post_as_get ( const std::string &  account_url,
const std::string &  resource_url,
std::function< bool(const ccf::http::HeaderMap &, const std::vector< uint8_t > &)>  ok_callback 
)
inlineprotected

◆ post_as_get_json()

void ACME::Client::post_as_get_json ( const std::string &  account_url,
const std::string &  resource_url,
std::function< bool(const ccf::http::HeaderMap &, const nlohmann::json &)>  ok_callback,
bool  empty_payload = false 
)
inlineprotected

◆ remove_order()

void ACME::Client::remove_order ( const std::string &  order_url)
inlineprotected

◆ request_authorization()

void ACME::Client::request_authorization ( Order order,
const std::string &  authz_url 
)
inlineprotected

◆ request_certificate()

void ACME::Client::request_certificate ( const std::string &  order_url)
inlineprotected

◆ request_directory()

void ACME::Client::request_directory ( )
inlineprotected

◆ request_finalization()

void ACME::Client::request_finalization ( const std::string &  order_url)
inlineprotected

◆ request_new_account()

void ACME::Client::request_new_account ( )
inlineprotected

◆ request_new_nonce()

void ACME::Client::request_new_nonce ( std::function< void()>  ok_callback)
inlineprotected

◆ request_new_order()

void ACME::Client::request_new_order ( const std::string &  account_url)
inlineprotected

◆ s2v()

static std::vector< uint8_t > ACME::Client::s2v ( const std::string &  s)
inlinestaticprotected

◆ schedule_check_challenge()

std::unique_ptr< threading::Tmsg< ChallengeWaitMsg > > ACME::Client::schedule_check_challenge ( const std::string &  order_url,
Challenge challenge 
)
inlineprotected

◆ schedule_check_finalization()

std::unique_ptr< threading::Tmsg< FinalizationWaitMsg > > ACME::Client::schedule_check_finalization ( const std::string &  order_url)
inlineprotected

◆ set_account_key()

virtual void ACME::Client::set_account_key ( std::shared_ptr< ccf::crypto::KeyPair new_account_key_pair)
inlinevirtual

Reimplemented in ccf::ACMEClient.

◆ start_challenge()

void ACME::Client::start_challenge ( const std::string &  token)
inline

◆ with_default_port()

static http::URL ACME::Client::with_default_port ( const std::string &  url,
const std::string &  default_port = "443" 
)
inlinestaticprotected

Member Data Documentation

◆ account

nlohmann::json ACME::Client::account
protected

◆ account_key_pair

std::shared_ptr<ccf::crypto::KeyPair> ACME::Client::account_key_pair
protected

◆ active_orders

std::list<Order> ACME::Client::active_orders
protected

◆ config

ClientConfig ACME::Client::config
protected

◆ directory

nlohmann::json ACME::Client::directory
protected

◆ last_request

std::optional<std::chrono::system_clock::time_point> ACME::Client::last_request
protected
Initial value:
=
std::nullopt

◆ nonces

std::list<std::string> ACME::Client::nonces
protected

◆ num_failed_attempts

size_t ACME::Client::num_failed_attempts = 0
protected

◆ orders_lock

ccf::pal::Mutex ACME::Client::orders_lock
protected

◆ req_lock

ccf::pal::Mutex ACME::Client::req_lock
protected

◆ service_key

std::shared_ptr<ccf::crypto::KeyPair> ACME::Client::service_key
protected

The documentation for this class was generated from the following file: