Skip to content

Commit

Permalink
Merge pull request #42 from conradludgate/main
Browse files Browse the repository at this point in the history
chore: update tokio-rustls
  • Loading branch information
tmccombs committed Dec 22, 2023
2 parents c707d5a + 4801141 commit 90f325a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -22,7 +22,7 @@ pin-project-lite = "0.2.13"
thiserror = "1.0.30"
tokio = { version = "1.0", features = ["time"] }
tokio-native-tls = { version = "0.3.0", optional = true }
tokio-rustls = { version = "0.24.0", optional = true }
tokio-rustls = { version = "0.25.0", optional = true }
tokio-openssl = { version = "0.6.3", optional = true }
openssl_impl = { package = "openssl", version = "0.10.32", optional = true }

Expand Down
12 changes: 7 additions & 5 deletions examples/tls_config/mod.rs
@@ -1,7 +1,10 @@
#[cfg(feature = "rustls")]
mod config {
use std::sync::Arc;
use tokio_rustls::rustls::{Certificate, PrivateKey, ServerConfig};
use tokio_rustls::rustls::{
pki_types::{CertificateDer, PrivateKeyDer},
ServerConfig,
};

const CERT: &[u8] = include_bytes!("local.cert");
const PKEY: &[u8] = include_bytes!("local.key");
Expand All @@ -12,12 +15,11 @@ mod config {

pub type Acceptor = tokio_rustls::TlsAcceptor;

fn tls_acceptor_impl(cert_der: &[u8], key_der: &[u8]) -> Acceptor {
let key = PrivateKey(cert_der.into());
let cert = Certificate(key_der.into());
fn tls_acceptor_impl(key_der: &[u8], cert_der: &[u8]) -> Acceptor {
let key = PrivateKeyDer::Pkcs1(key_der.to_owned().into());
let cert = CertificateDer::from(cert_der).into_owned();
Arc::new(
ServerConfig::builder()
.with_safe_defaults()
.with_no_client_auth()
.with_single_cert(vec![cert], key)
.unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions tests/basic.rs
Expand Up @@ -76,14 +76,14 @@ async fn tls_error() {
);
}

static LONG_TEXT: &'static [u8] = include_bytes!("long_text.txt");
static LONG_TEXT: &[u8] = include_bytes!("long_text.txt");

#[tokio::test]
async fn echo() {
let (ender, ended) = oneshot::channel();
let (connector, listener) = setup_echo(ended);

async fn check_message(c: &MockConnect, msg: &[u8]) -> () {
async fn check_message(c: &MockConnect, msg: &[u8]) {
let resp = c.send_data(msg).await;
assert_ascii_eq!(resp.unwrap(), msg.to_ascii_lowercase());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/helper/mocks.rs
Expand Up @@ -116,7 +116,7 @@ impl AsyncWrite for MockTlsStream {
buf: &[u8],
) -> Poll<io::Result<usize>> {
let data = buf.to_ascii_lowercase();
self.inner().poll_write(cx, &*data)
self.inner().poll_write(cx, &data)
}

fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
Expand Down

0 comments on commit 90f325a

Please sign in to comment.