Debian Codegraph @

crt/s2n/bindings/rust/standard/s2n-tls-hyper/tests/common/mod.rs

raw symbols SCIP
1 // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 // SPDX-License-Identifier: Apache-2.0
3
4 use s2n_tls::{callbacks::VerifyHostNameCallback, config, error::Error, security::DEFAULT_TLS13};
5
6 pub mod echo;
7
8 /// NOTE: this certificate and key are used for testing purposes only!
9 pub const CERT_PEM: &[u8] =
10 include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../certs/cert.pem"));
11 pub const KEY_PEM: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/../certs/key.pem"));
12
13 pub fn config() -> Result<config::Builder, Error> {
14 let mut builder = config::Config::builder();
15 builder.set_security_policy(&DEFAULT_TLS13)?;
16 builder.trust_pem(CERT_PEM)?;
17 builder.load_pem(CERT_PEM, KEY_PEM)?;
18 Ok(builder)
19 }
20
21 pub struct InsecureAcceptAllCertificatesHandler {}
22 impl VerifyHostNameCallback for InsecureAcceptAllCertificatesHandler {
23 fn verify_host_name(&self, _host_name: &str) -> bool {
24 true
25 }
26 }