Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ readme = "README.md"
anyhow = "1.0"
arc-swap = "1"
base64 = "0.22"
bytes = "1.6"
chrono = "0.4"
http = "1.3"
itertools = { version = "0.14", optional = true }
prometheus = { version = "0.14", optional = true }
rasn = "0.15"
rasn-ocsp = "0.15"
rasn-pkix = "0.15"
rasn = "0.28"
rasn-ocsp = "0.28"
rasn-pkix = "0.28"
reqwest = { version = "0.12", default-features = false, features = [
"rustls-tls-webpki-roots-no-provider",
"http2",
Expand All @@ -41,10 +40,10 @@ tokio = { version = "1.44", features = ["full"] }
tokio-util = { version = "0.7", features = ["full"] }
tracing = "0.1"
url = "2.5"
x509-parser = "0.16"
x509-parser = "0.18"

[dev-dependencies]
hex-literal = "0.4"
hex-literal = "1.1"
rustls-pemfile = "2"
num-bigint = "0.4"
httptest = "0.16"
Expand Down
26 changes: 15 additions & 11 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use std::time::Duration;

use anyhow::{anyhow, Context, Error};
use base64::prelude::*;
use bytes::Bytes;
use http::{header::CONTENT_TYPE, StatusCode};
use rasn::types::Oid;
use num_bigint::BigInt;
use rasn::types::{OctetString, Oid};
use rasn_ocsp::{
BasicOcspResponse, CertId, CertStatus, OcspRequest, OcspResponse, OcspResponseStatus, Request,
TbsRequest, Version,
Expand Down Expand Up @@ -77,14 +77,15 @@ fn prepare_ocsp_request(cert: &[u8], issuer: &[u8]) -> Result<(OcspRequest, Url)
};

// Calculate the hashes required for OCSP request
let issuer_name_hash = Bytes::copy_from_slice(Sha1::digest(cert.issuer.as_raw()).as_slice());
let issuer_name_hash = OctetString::from_slice(Sha1::digest(cert.issuer.as_raw()).as_slice());
let issuer_key_hash =
Bytes::copy_from_slice(Sha1::digest(&issuer.public_key().subject_public_key).as_slice());
OctetString::from_slice(Sha1::digest(&issuer.public_key().subject_public_key).as_slice());

// Prepare the request
let serial_number: BigInt = cert.serial.clone().into();
let req_cert = CertId {
hash_algorithm,
serial_number: cert.serial.clone().into(),
serial_number: serial_number.into(),
issuer_name_hash,
issuer_key_hash,
};
Expand Down Expand Up @@ -246,6 +247,7 @@ pub(crate) mod test {

use hex_literal::hex;
use httptest::{matchers::*, responders::*, Expectation, Server};
use rasn::types::{Integer, OctetString};
use rustls::{crypto::ring, sign::CertifiedKey};

const OCSP_REQUEST: &[u8] = include_bytes!("../test/ocsp_request.bin");
Expand All @@ -265,16 +267,18 @@ pub(crate) mod test {
.to_owned(),
parameters: None,
},
issuer_name_hash: Bytes::from(
issuer_name_hash: OctetString::from(
&hex!("36175FAA02C887BDD95CA13549512D1E97FADFA9")[..],
),
issuer_key_hash: Bytes::from(
issuer_key_hash: OctetString::from(
&hex!("6691287B8D8654BAF6203197AEC491E9AFB70BCB")[..],
),
serial_number: num_bigint::BigInt::from_str(
"3819096869935823013274658159093914787918510",
)
.unwrap(),
serial_number: Integer::from(
num_bigint::BigInt::from_str(
"3819096869935823013274658159093914787918510",
)
.unwrap(),
),
},
single_request_extensions: None,
}],
Expand Down
Binary file modified test/ocsp_request.bin
Binary file not shown.