Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
blind-oracle committed May 25, 2024
1 parent 50c2c47 commit 7f6fdb9
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ocsp-stapler"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
license = "MPL-2.0"
description = "OCSP stapler & client with support for Rustls"
Expand All @@ -15,7 +15,7 @@ categories = [
"web-programming::http-server",
]

readme = "README_CARGO.md"
readme = "README_DOCS.md"

[dependencies]
anyhow = "1.0"
Expand Down Expand Up @@ -51,3 +51,6 @@ num-bigint = "0.4"

[lib]
doctest = false

[build-dependencies]
readme-rustdocifier = "0.1.0"
2 changes: 1 addition & 1 deletion README_CARGO.md → README_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Other notes:

Stapler supports a few Prometheus metrics - create it using one of `new_..._with_registry()` constructors and provide a Prometheus `Registry` reference to register the metrics in.

# Example
### Example

```rust,ignore
// Inner service that provides certificates to Rustls, can be anything
Expand Down
19 changes: 19 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::{env, error::Error, fs, path::PathBuf};

const CRATE_NAME: &str = "ocsp-stapler";

fn main() -> Result<(), Box<dyn Error>> {
println!("cargo:rerun-if-changed=README_DOCS.md");

fs::write(
PathBuf::from(env::var("OUT_DIR")?).join("README-rustdocified.md"),
readme_rustdocifier::rustdocify(
&fs::read_to_string("README_DOCS.md")?,
&env::var("CARGO_PKG_NAME")?,
Some(&env::var("CARGO_PKG_VERSION")?),
Some(CRATE_NAME),
)?,
)?;

Ok(())
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![warn(clippy::all)]
#![warn(clippy::nursery)]
#![doc = include_str!(concat!(env!("OUT_DIR"), "/README-rustdocified.md"))]

pub mod client;
pub mod stapler;
Expand Down
11 changes: 8 additions & 3 deletions src/stapler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,16 @@ impl StaplerActor {
.context("unable to parse certificate as X.509")?
.1;

let cert_validity =
Validity::try_from(&cert.validity).context("unable to parse certificate validity")?;
let cert_validity = Validity::try_from(&cert.validity).context(format!(
"unable to parse certificate [{}] validity",
cert.subject
))?;

if !cert_validity.valid(Utc::now().into()) {
return Err(anyhow!("The certificate is not valid at current time"));
return Err(anyhow!(
"the certificate [{}] is not valid at current time",
cert.subject
));
}

let cert = Cert {
Expand Down

0 comments on commit 7f6fdb9

Please sign in to comment.