Skip to content

Commit

Permalink
fix(tls): change tls to native_tls for re-exports
Browse files Browse the repository at this point in the history
  • Loading branch information
compressed committed Jan 31, 2017
1 parent f0dd32e commit 7c9cca8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ with the `tls` feature flag enabled.
When using TLS, some additional information is required. You will need to make [`TlsAcceptor`] and
`client::tls::Context` structs; `client::tls::Context` requires a [`TlsConnector`]. The
[`TlsAcceptor`] and [`TlsConnector`] types are defined in the [native-tls]. tarpc re-exports
external TLS-related types in its `tls` module (`tarpc::tls`).
external TLS-related types in its `native_tls` module (`tarpc::native_tls`).

[TLS]: https://en.wikipedia.org/wiki/Transport_Layer_Security
[`TcpStream`]: https://docs.rs/tokio-core/0.1/tokio_core/net/struct.TcpStream.html
Expand All @@ -172,7 +172,7 @@ use tarpc::{client, server};
use tarpc::client::future::Connect;
use tarpc::util::{FirstSocketAddr, Never};
use tokio_core::reactor;
use tarpc::tls::{Pkcs12, TlsAcceptor};
use tarpc::native_tls::{Pkcs12, TlsAcceptor};

service! {
rpc hello(name: String) -> String;
Expand Down
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type BindClient<Req, Resp, E> = <Proto<Req, Result<Resp, WireError<E>>> as
/// TLS-specific functionality
#[cfg(feature = "tls")]
pub mod tls {
use native_tls::TlsConnector;
use native_tls::{Error, TlsConnector};

/// TLS context for client
pub struct Context {
Expand All @@ -43,7 +43,7 @@ pub mod tls {
/// The provided domain will be used for both
/// [SNI](https://en.wikipedia.org/wiki/Server_Name_Indication) and certificate hostname
/// validation.
pub fn new<S: Into<String>>(domain: S) -> Result<Self, ::tls::NativeTlsError> {
pub fn new<S: Into<String>>(domain: S) -> Result<Self, Error> {
Ok(Context {
domain: domain.into(),
tls_connector: TlsConnector::builder()?.build()?,
Expand Down
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
//! use tarpc::{client, server};
//! use tarpc::client::sync::Connect;
//! use tarpc::util::Never;
//! use tarpc::tls::{TlsAcceptor, Pkcs12};
//! use tarpc::native_tls::{TlsAcceptor, Pkcs12};
//!
//! service! {
//! rpc hello(name: String) -> String;
Expand Down Expand Up @@ -192,12 +192,11 @@ enum Reactor {
cfg_if! {
if #[cfg(feature = "tls")] {
extern crate tokio_tls;
extern crate native_tls;
extern crate native_tls as native_tls_inner;

/// Re-exported TLS-related types
pub mod tls {
pub use native_tls::Error as NativeTlsError;
pub use native_tls::{Pkcs12, TlsAcceptor, TlsConnector};
pub mod native_tls {
pub use native_tls_inner::{Error, Pkcs12, TlsAcceptor, TlsConnector};
}
} else {}
}
6 changes: 3 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ mod functional_test {
const DOMAIN: &'static str = "foobar.com";

use client::tls::Context;
use ::native_tls::{Pkcs12, TlsAcceptor, TlsConnector};
use native_tls::{Pkcs12, TlsAcceptor, TlsConnector};

fn tls_context() -> (server::Options, client::Options) {
let buf = include_bytes!("../test/identity.p12");
Expand All @@ -741,7 +741,7 @@ mod functional_test {
extern crate security_framework;

use self::security_framework::certificate::SecCertificate;
use native_tls::backend::security_framework::TlsConnectorBuilderExt;
use native_tls_inner::backend::security_framework::TlsConnectorBuilderExt;

fn get_tls_client_options() -> client::Options {
let buf = include_bytes!("../test/root-ca.der");
Expand All @@ -755,7 +755,7 @@ mod functional_test {
})
}
} else if #[cfg(all(not(target_os = "macos"), not(windows)))] {
use native_tls::backend::openssl::TlsConnectorBuilderExt;
use native_tls_inner::backend::openssl::TlsConnectorBuilderExt;

fn get_tls_client_options() -> client::Options {
let mut connector = unwrap!(TlsConnector::builder());
Expand Down

0 comments on commit 7c9cca8

Please sign in to comment.