From 6336ef1ab7ccb8691dfbb350dd81f15fb923a2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kj=C3=A4ll?= Date: Sun, 2 Jan 2022 18:57:29 +0100 Subject: [PATCH 1/2] include the identity.p12 and root-ca.der files into the test binary, so that the tests can be run from different directories with less trouble --- tokio-native-tls/tests/smoke.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tokio-native-tls/tests/smoke.rs b/tokio-native-tls/tests/smoke.rs index 994fdde..ffa50a6 100644 --- a/tokio-native-tls/tests/smoke.rs +++ b/tokio-native-tls/tests/smoke.rs @@ -135,13 +135,13 @@ async fn one_byte_at_a_time() { } fn context() -> (TlsAcceptor, TlsConnector) { - let pkcs12 = fs::read(CERT_DIR.join("identity.p12")).unwrap(); - let der = fs::read(CERT_DIR.join("root-ca.der")).unwrap(); + let pkcs12 = include_bytes!("identity.p12"); + let der = include_bytes!("root-ca.der"); - let identity = Identity::from_pkcs12(&pkcs12, "mypass").unwrap(); + let identity = Identity::from_pkcs12(pkcs12, "mypass").unwrap(); let acceptor = native_tls::TlsAcceptor::builder(identity).build().unwrap(); - let cert = Certificate::from_der(&der).unwrap(); + let cert = Certificate::from_der(der).unwrap(); let connector = native_tls::TlsConnector::builder() .add_root_certificate(cert) .build() From 41319bf3118978843a0bd3f3301200cbed45d7fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kj=C3=A4ll?= Date: Sun, 2 Jan 2022 21:24:42 +0100 Subject: [PATCH 2/2] removed unused import --- tokio-native-tls/tests/smoke.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokio-native-tls/tests/smoke.rs b/tokio-native-tls/tests/smoke.rs index ffa50a6..20520d5 100644 --- a/tokio-native-tls/tests/smoke.rs +++ b/tokio-native-tls/tests/smoke.rs @@ -1,7 +1,7 @@ use futures::join; use lazy_static::lazy_static; use native_tls::{Certificate, Identity}; -use std::{fs, io::Error, path::PathBuf, process::Command}; +use std::{io::Error, path::PathBuf, process::Command}; use tokio::{ io::{AsyncReadExt, AsyncWrite, AsyncWriteExt}, net::{TcpListener, TcpStream},