wstunnel/src/embedded_certificate.rs

24 lines
846 B
Rust
Raw Normal View History

use log::info;
2024-08-26 18:33:25 +00:00
use std::sync::LazyLock;
2024-05-09 11:33:23 +00:00
use tokio_rustls::rustls::pki_types::{CertificateDer, PrivateKeyDer};
2024-08-26 18:33:25 +00:00
pub static TLS_PRIVATE_KEY: LazyLock<PrivateKeyDer<'static>> = LazyLock::new(|| {
info!("Loading embedded tls private key");
let key = include_bytes!("../certs/key.pem");
let key = rustls_pemfile::private_key(&mut key.as_slice())
.expect("failed to load embedded tls private key")
.expect("failed to load embedded tls private key");
2024-05-09 11:33:23 +00:00
key
});
2024-08-26 18:33:25 +00:00
pub static TLS_CERTIFICATE: LazyLock<Vec<CertificateDer<'static>>> = LazyLock::new(|| {
info!("Loading embedded tls certificate");
let cert = include_bytes!("../certs/cert.pem");
let certs = rustls_pemfile::certs(&mut cert.as_slice())
.next()
.expect("failed to load embedded tls certificate");
2024-05-09 11:33:23 +00:00
certs.into_iter().collect()
});