v0.34.10
This commit is contained in:
1 parent
66ff9dfaa2
commit
ee54aa6875
30 files changed
+939
-68
No files matched your search
@@ -1,3 +1,49 @@
|
||||
#[derive(Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct CertificateInspection {
|
||||
cert_file: String,
|
||||
}
|
||||
|
||||
async fn certificate_inspect(
|
||||
State(state): State<Arc<App>>,
|
||||
Json(input): Json<CertificateInspection>,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let directory = state.policy.cert_dir.clone().ok_or_else(|| {
|
||||
ApiError(
|
||||
StatusCode::CONFLICT,
|
||||
"certificate storage is unavailable; configure the certificate directory".into(),
|
||||
)
|
||||
})?;
|
||||
let permit = state
|
||||
.certificate_slots
|
||||
.clone()
|
||||
.try_acquire_owned()
|
||||
.map_err(|_| {
|
||||
ApiError(
|
||||
StatusCode::TOO_MANY_REQUESTS,
|
||||
"certificate inspection queue is full".into(),
|
||||
)
|
||||
})?;
|
||||
let cert_file = input.cert_file;
|
||||
let (cert_file, metadata) = tokio::task::spawn_blocking(move || {
|
||||
let _permit = permit;
|
||||
crate::tls::certificate_metadata(&directory, &cert_file)
|
||||
.map(|metadata| (cert_file, metadata))
|
||||
})
|
||||
.await
|
||||
.map_err(|_| {
|
||||
ApiError(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
"certificate inspection task failed".into(),
|
||||
)
|
||||
})?
|
||||
.map_err(|error| ApiError(StatusCode::UNPROCESSABLE_ENTITY, format!("{error:#}")))?;
|
||||
Ok(Json(json!({
|
||||
"cert_file": cert_file,
|
||||
"covered_hosts": metadata.covered_hosts,
|
||||
})))
|
||||
}
|
||||
|
||||
async fn certificate_deploy(
|
||||
State(state): State<Arc<App>>,
|
||||
Extension(session): Extension<Session>,
|
||||
|
||||
Reference in new issue
Block a user