All checks were successful
continuous-integration/drone/push Build is passing
33 lines
903 B
Rust
33 lines
903 B
Rust
use crate::app_config::AppConfig;
|
|
use crate::server::custom_error::HttpResult;
|
|
use actix_web::{HttpResponse, web};
|
|
|
|
#[derive(serde::Deserialize)]
|
|
pub struct ServeCRLPath {
|
|
file: String,
|
|
}
|
|
|
|
/// Serve PKI files (unsecure server)
|
|
pub async fn serve_pki_file(path: web::Path<ServeCRLPath>) -> HttpResult {
|
|
for f in std::fs::read_dir(AppConfig::get().pki_path())? {
|
|
let f = f?;
|
|
let file_name = f.file_name().to_string_lossy().to_string();
|
|
if !file_name.ends_with(".crl") && !file_name.ends_with(".crt") {
|
|
continue;
|
|
}
|
|
|
|
if file_name != path.file {
|
|
continue;
|
|
}
|
|
|
|
let crl = std::fs::read(f.path())?;
|
|
return Ok(HttpResponse::Ok()
|
|
.content_type("application/x-pem-file")
|
|
.body(crl));
|
|
}
|
|
|
|
Ok(HttpResponse::NotFound()
|
|
.content_type("text/plain")
|
|
.body("file not found!"))
|
|
}
|