Skip to content

Commit b9b4b0c

Browse files
committed
Ready for publish
1 parent be9c398 commit b9b4b0c

File tree

9 files changed

+29
-32
lines changed

9 files changed

+29
-32
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "async-tls"
3-
version = "0.1.0-alpha.0"
4-
authors = ["Florian Gilcher <[email protected]>", "dignifiedquire <[email protected]>", "quininer kel <[email protected]>"]
3+
version = "0.5.0"
4+
authors = ["The async-rs developers", "Florian Gilcher <[email protected]>", "dignifiedquire <[email protected]>", "quininer kel <[email protected]>"]
55
license = "MIT/Apache-2.0"
66
repository = "https://github.com/async-std/async-tls"
77
homepage = "https://github.com/async-std/async-tls"
@@ -16,7 +16,7 @@ travis-ci = { repository = "async-std/async-tls" }
1616
appveyor = { repository = "async-std/async-tls" }
1717

1818
[dependencies]
19-
futures-preview = "0.3.0-alpha.17"
19+
futures-preview = "0.3.0-alpha.19"
2020
rustls = "0.16"
2121
webpki = "0.21"
2222
webpki-roots = "0.17"

examples/client/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "client"
3-
version = "0.1.0"
4-
authors = ["quininer <[email protected]>"]
3+
version = "0.5.0"
4+
authors = ["The async-rs authors", "quininer <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]

examples/client/src/main.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
#![feature(async_await)]
2-
31
use async_std::io;
42
use async_std::io::Write;
53
use async_std::net::TcpStream;
64
use async_std::task;
75
use async_tls::TlsConnector;
6+
87
use rustls::ClientConfig;
9-
use std::sync::Arc;
10-
use std::fs::File;
11-
use std::io::BufReader;
8+
9+
use std::io::Cursor;
1210
use std::net::ToSocketAddrs;
1311
use std::path::{Path, PathBuf};
12+
use std::sync::Arc;
13+
1414
use structopt::StructOpt;
1515

1616
#[derive(StructOpt)]
@@ -48,15 +48,17 @@ fn main() -> io::Result<()> {
4848
// Create a bare bones HTTP GET request
4949
let http_request = format!("GET / HTTP/1.0\r\nHost: {}\r\n\r\n", domain);
5050

51-
// Create default connector comes preconfigured with all you need to safely connect
52-
// to remote servers!
53-
let connector = if let Some(cafile) = &options.cafile {
54-
connector_for_ca_file(cafile)?
55-
} else {
56-
TlsConnector::default()
57-
};
51+
let cafile = &options.cafile;
52+
53+
task::block_on(async move {
54+
// Create default connector comes preconfigured with all you need to safely connect
55+
// to remote servers!
56+
let connector = if let Some(cafile) = cafile {
57+
connector_for_ca_file(cafile).await?
58+
} else {
59+
TlsConnector::default()
60+
};
5861

59-
task::block_on(async {
6062
// Open a normal TCP connection, just as you are used to
6163
let tcp_stream = TcpStream::connect(&addr).await?;
6264

@@ -81,12 +83,13 @@ fn main() -> io::Result<()> {
8183
})
8284
}
8385

84-
fn connector_for_ca_file(cafile: &Path) -> io::Result<TlsConnector> {
86+
async fn connector_for_ca_file(cafile: &Path) -> io::Result<TlsConnector> {
8587
let mut config = ClientConfig::new();
86-
let mut pem = BufReader::new(File::open(cafile)?);
88+
let file = async_std::fs::read(cafile).await?;
89+
let mut pem = Cursor::new(file);
8790
config
8891
.root_store
8992
.add_pem_file(&mut pem)
9093
.map_err(|_| io::Error::new(io::ErrorKind::InvalidInput, "invalid cert"))?;
9194
Ok(TlsConnector::from(Arc::new(config)))
92-
}
95+
}

examples/server/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "server"
3-
version = "0.1.0"
4-
authors = ["quininer <[email protected]>"]
3+
version = "0.5.0"
4+
authors = ["The async-rs developers", "quininer <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]

examples/server/src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(async_await)]
2-
31
use async_std::io;
42
use async_std::io::Write;
53
use async_std::net::{TcpListener, TcpStream};

src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
//! Asynchronous TLS/SSL streams for async-std and AsyncRead/AsyncWrite sockets using [rustlsz](https://github.com/ctz/rustls).
1+
//! Asynchronous TLS/SSL streams for async-std and AsyncRead/AsyncWrite sockets using [rustls](https://github.com/ctz/rustls).
22
3-
#![feature(async_await)]
43
#![deny(unsafe_code)]
54

65
pub mod client;
@@ -11,4 +10,4 @@ mod connector;
1110
mod acceptor;
1211

1312
pub use acceptor::TlsAcceptor as TlsAcceptor;
14-
pub use connector::TlsConnector as TlsConnector;
13+
pub use connector::TlsConnector as TlsConnector;

src/rusttls/stream.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,5 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> AsyncWrite for Stream<'
258258
}
259259

260260
#[cfg(test)]
261+
#[path="test_stream.rs"]
261262
mod test_stream;

tests/google.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(async_await)]
2-
31
use async_std::net::TcpStream;
42
use async_std::task;
53
use async_tls::TlsConnector;

tests/test.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(async_await)]
2-
31
use async_std::net::{TcpListener, TcpStream};
42
use async_tls::{TlsAcceptor, TlsConnector};
53
use futures::executor;

0 commit comments

Comments
 (0)