MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / build

Method build

certbot/src/bot.rs:89–132  ·  view source on GitHub ↗

Build a new `CertBot` from a `CertBotConfig`.

(config: CertBotConfig)

Source from the content-addressed store, hash-verified

87impl CertBot {
88 /// Build a new `CertBot` from a `CertBotConfig`.
89 pub async fn build(config: CertBotConfig) -> Result<Self> {
90 let base_domain = config
91 .cert_subject_alt_names
92 .first()
93 .context("cert_subject_alt_names is empty")?
94 .trim()
95 .trim_start_matches("*.")
96 .trim_end_matches('.')
97 .to_string();
98 let dns01_client = Dns01Client::new_cloudflare(
99 base_domain,
100 config.cf_api_token.clone(),
101 config.cf_api_url.clone(),
102 )
103 .await?;
104 let acme_client = match fs::read_to_string(&config.credentials_file) {
105 Ok(credentials) => {
106 if acme_matches(&credentials, &config.acme_url) {
107 AcmeClient::load(
108 dns01_client,
109 &credentials,
110 config.max_dns_wait,
111 config.dns_txt_ttl,
112 )
113 .await?
114 } else {
115 create_new_account(&config, dns01_client).await?
116 }
117 }
118 Err(e) if e.kind() == ErrorKind::NotFound => {
119 if !config.auto_create_account {
120 return Err(e).context("credentials file not found");
121 }
122 create_new_account(&config, dns01_client).await?
123 }
124 Err(e) => {
125 return Err(e).context("failed to read credentials file");
126 }
127 };
128 Ok(Self {
129 acme_client,
130 config,
131 })
132 }
133
134 /// Get the ACME account ID.
135 pub fn account_id(&self) -> &str {

Callers 15

from_keysMethod · 0.45
onboardMethod · 0.45
gen_ra_certFunction · 0.45
derive_app_caMethod · 0.45
build_clientFunction · 0.45
http_requestFunction · 0.45
vsockMethod · 0.45
test_tls_key_uniquenessFunction · 0.45
mainFunction · 0.45
cmd_gen_ca_certFunction · 0.45
make_app_keysFunction · 0.45

Calls 4

acme_matchesFunction · 0.85
create_new_accountFunction · 0.85
cloneMethod · 0.80
kindMethod · 0.80