(config: &PathBuf)
| 120 | } |
| 121 | |
| 122 | fn load_config(config: &PathBuf) -> Result<CertBotConfig> { |
| 123 | let config: Config = toml_edit::de::from_str(&fs::read_to_string(config)?)?; |
| 124 | let workdir = WorkDir::new(&config.workdir); |
| 125 | let renew_interval = Duration::from_secs(config.renew_interval); |
| 126 | let renew_expires_in = Duration::from_secs(config.renew_days_before * 24 * 60 * 60); |
| 127 | let renew_timeout = Duration::from_secs(config.renew_timeout); |
| 128 | let max_dns_wait = Duration::from_secs(config.max_dns_wait); |
| 129 | let bot_config = CertBotConfig::builder() |
| 130 | .acme_url(config.acme_url) |
| 131 | .cert_dir(workdir.backup_dir()) |
| 132 | .cert_file(workdir.cert_path()) |
| 133 | .key_file(workdir.key_path()) |
| 134 | .auto_create_account(true) |
| 135 | .cert_subject_alt_names(config.domains) |
| 136 | .cf_api_token(config.cf_api_token) |
| 137 | .renew_interval(renew_interval) |
| 138 | .renew_timeout(renew_timeout) |
| 139 | .renew_expires_in(renew_expires_in) |
| 140 | .max_dns_wait(max_dns_wait) |
| 141 | .credentials_file(workdir.account_credentials_path()) |
| 142 | .auto_set_caa(config.auto_set_caa) |
| 143 | .maybe_renewed_hook(config.renewed_hook) |
| 144 | .build(); |
| 145 | Ok(bot_config) |
| 146 | } |
| 147 | |
| 148 | async fn renew(config: &PathBuf, once: bool, force: bool) -> Result<()> { |
| 149 | let bot_config = load_config(config).context("Failed to load configuration")?; |
no test coverage detected