mirror of https://github.com/http-rs/tide-rustls
Compare commits
5 Commits
ea41f9ff1b
...
635ecf075d
Author | SHA1 | Date |
---|---|---|
Jacob Rothstein | 635ecf075d | |
Josh Triplett | 2990e7d4a0 | |
Jacob Rothstein | 895760f75e | |
Josh Triplett | 0306e915b0 | |
Josh Triplett | e8ea6d0e0b |
|
@ -1,9 +1,9 @@
|
|||
[package]
|
||||
name = "tide-rustls"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
authors = ["Jacob Rothstein <hi@jbr.me>"]
|
||||
edition = "2018"
|
||||
description = "tide tls listener based on async-tls and rustls"
|
||||
description = "tide tls listener based on async-rustls and rustls"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/jbr/tide-rustls"
|
||||
documentation = "https://docs.rs/tide-rustls"
|
||||
|
@ -14,7 +14,7 @@ categories = ["web-programming::http-server", "web-programming"]
|
|||
[dependencies]
|
||||
async-std = "1.7.0"
|
||||
tide = { version = "0.16.0", default-features = false }
|
||||
async-tls = "0.11.0"
|
||||
async-rustls = "0.2.0"
|
||||
rustls = "0.19.0"
|
||||
async-h1 = "2.2.0"
|
||||
async-dup = "1.2.2"
|
||||
|
|
|
@ -41,5 +41,5 @@ pub(crate) use tls_stream_wrapper::TlsStreamWrapper;
|
|||
pub use tls_listener::TlsListener;
|
||||
pub use tls_listener_builder::TlsListenerBuilder;
|
||||
|
||||
pub use async_tls;
|
||||
pub use async_rustls;
|
||||
pub use rustls;
|
||||
|
|
|
@ -8,7 +8,7 @@ use async_std::net::{TcpListener, TcpStream};
|
|||
use async_std::prelude::*;
|
||||
use async_std::{io, task};
|
||||
|
||||
use async_tls::TlsAcceptor;
|
||||
use async_rustls::TlsAcceptor;
|
||||
use rustls::internal::pemfile::{certs, pkcs8_private_keys, rsa_private_keys};
|
||||
use rustls::{Certificate, NoClientAuth, PrivateKey, ServerConfig};
|
||||
|
||||
|
@ -69,7 +69,7 @@ impl<State> TlsListener<State> {
|
|||
TlsListenerBuilder::new()
|
||||
}
|
||||
|
||||
async fn configure(&mut self) -> io::Result<TlsAcceptor> {
|
||||
async fn configure(&mut self) -> io::Result<()> {
|
||||
self.config = match std::mem::take(&mut self.config) {
|
||||
TlsListenerConfig::Paths { cert, key } => {
|
||||
let certs = load_certs(&cert)?;
|
||||
|
@ -86,17 +86,17 @@ impl<State> TlsListener<State> {
|
|||
TlsListenerConfig::Acceptor(TlsAcceptor::from(Arc::new(config)))
|
||||
}
|
||||
|
||||
other => other,
|
||||
other @ TlsListenerConfig::Acceptor(_) => other,
|
||||
|
||||
TlsListenerConfig::Unconfigured => {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"could not configure tlslistener",
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
if let TlsListenerConfig::Acceptor(ref a) = self.config {
|
||||
Ok(a.clone())
|
||||
} else {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"could not configure tlslistener",
|
||||
))
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn acceptor(&self) -> Option<&TlsAcceptor> {
|
||||
|
@ -113,17 +113,12 @@ impl<State> TlsListener<State> {
|
|||
}
|
||||
}
|
||||
|
||||
async fn connect(&mut self) -> io::Result<&TcpListener> {
|
||||
async fn connect(&mut self) -> io::Result<()> {
|
||||
if let TcpConnection::Addrs(addrs) = &self.connection {
|
||||
let tcp = TcpListener::bind(&addrs[..]).await?;
|
||||
self.connection = TcpConnection::Connected(tcp);
|
||||
}
|
||||
|
||||
if let TcpConnection::Connected(tcp) = &self.connection {
|
||||
Ok(tcp)
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::fmt::{self, Debug, Formatter};
|
||||
|
||||
use async_tls::TlsAcceptor;
|
||||
use async_rustls::TlsAcceptor;
|
||||
use rustls::ServerConfig;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use async_dup::{Arc, Mutex};
|
||||
use async_rustls::server::TlsStream;
|
||||
use async_std::io::{Read, Result, Write};
|
||||
use async_std::net::TcpStream;
|
||||
use async_tls::server::TlsStream;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
|
|
Loading…
Reference in New Issue