use std::sync::Arc;
use crate::error::Result;
pub const ACME_CHALLENGE_PATH_PREFIX: &str = crate::solvers::http::HTTP01_PREFIX;
pub const ZEROSSL_VALIDATION_PATH_PREFIX: &str = "/.well-known/pki-validation/";
pub use crate::solvers::http::HttpChallengeHandler;
pub use crate::solvers::http::HttpChallengeMap;
#[must_use]
pub fn is_challenge_request(path: &str) -> bool {
path.starts_with(ACME_CHALLENGE_PATH_PREFIX)
}
#[must_use]
pub fn extract_challenge_token(path: &str) -> Option<&str> {
crate::solvers::http::extract_http_challenge_token(path)
}
#[must_use]
pub fn is_valid_challenge_token(token: &str) -> bool {
crate::solvers::http::is_valid_http_challenge_token(token)
}
pub async fn handle_http_request(
handler: &HttpChallengeHandler,
method: &str,
host: &str,
path: &str,
) -> Option<(u16, String)> {
handler.handle_http_request(method, host, path).await
}
#[must_use]
pub fn https_redirect_url(host: &str, path: &str) -> String {
crate::https::HttpsRedirectHandler::default().redirect_url(host, path)
}
#[must_use]
pub fn handler_map() -> HttpChallengeMap {
Arc::new(tokio::sync::RwLock::new(std::collections::HashMap::new()))
}
pub async fn handle_request(handler: &HttpChallengeHandler, path: &str) -> Option<String> {
handler.handle_request(path).await
}
pub async fn handle_request_blind(
handler: &HttpChallengeHandler,
path: &str,
account_thumbprint: Option<&str>,
) -> Option<String> {
handler.handle_request_blind(path, account_thumbprint).await
}
pub fn try_https_redirect_url(host: &str, path: &str) -> Result<String> {
let handler = crate::https::HttpsRedirectHandler::new(443).with_canonical_host(host)?;
handler.try_redirect_url(host, path)
}