Skip to content

Commit

Permalink
testing: make example cert/key files relative to Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse authored and ghedo committed Jun 27, 2024
1 parent 4ff56ec commit 0a7b6c4
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions quiche/src/h3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2878,9 +2878,22 @@ pub mod testing {

impl Session {
pub fn new() -> Result<Session> {
fn path_relative_to_manifest_dir(path: &str) -> String {
std::fs::canonicalize(
std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join(path),
)
.unwrap()
.to_string_lossy()
.into_owned()
}

let mut config = crate::Config::new(crate::PROTOCOL_VERSION)?;
config.load_cert_chain_from_pem_file("examples/cert.crt")?;
config.load_priv_key_from_pem_file("examples/cert.key")?;
config.load_cert_chain_from_pem_file(
&path_relative_to_manifest_dir("examples/cert.crt"),
)?;
config.load_priv_key_from_pem_file(
&path_relative_to_manifest_dir("examples/cert.key"),
)?;
config.set_application_protos(&[b"h3"])?;
config.set_initial_max_data(1500);
config.set_initial_max_stream_data_bidi_local(150);
Expand Down

0 comments on commit 0a7b6c4

Please sign in to comment.