Skip to content

Commit 8506050

Browse files
jen20LucioFranco
authored andcommitted
fix(transport): Remove support for OpenSSL (#141)
BREAKING CHANGE: Remove support for OpenSSL within the transport.
1 parent c63c107 commit 8506050

File tree

14 files changed

+82
-465
lines changed

14 files changed

+82
-465
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ jobs:
7474
- name: Run tests
7575
run: cargo test --all --all-features
7676

77-
interop-unix:
78-
name: Interop Tests (Rustls & OpenSSL)
77+
interop:
78+
name: Interop Tests
7979
runs-on: ${{ matrix.os }}
8080
strategy:
8181
matrix:
82-
os: [ubuntu-latest, macOS-latest]
82+
os: [ubuntu-latest, macOS-latest, windows-latest]
8383
rust: [stable]
8484

8585
env:
@@ -98,30 +98,3 @@ jobs:
9898
- name: Run interop tests with Rustls
9999
run: ./tonic-interop/test.sh --use_tls tls_rustls
100100
shell: bash
101-
- name: Run interop tests with OpenSSL
102-
run: ./tonic-interop/test.sh --use_tls tls_openssl
103-
shell: bash
104-
105-
interop-windows:
106-
name: Interop Tests (Rustls) (Windows)
107-
runs-on: windows-latest
108-
strategy:
109-
matrix:
110-
rust: [stable]
111-
112-
env:
113-
RUSTFLAGS: "-D warnings"
114-
115-
steps:
116-
- uses: hecrj/setup-rust-action@master
117-
with:
118-
rust-version: ${{ matrix.rust }}
119-
- name: Install rustfmt
120-
run: rustup component add rustfmt
121-
- uses: actions/checkout@master
122-
- name: Run interop tests
123-
run: ./tonic-interop/test.sh
124-
shell: bash
125-
- name: Run interop tests with Rustls
126-
run: ./tonic-interop/test.sh --use_tls tls_rustls
127-
shell: bash

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ contains the tools to build clients and servers from [`protobuf`] definitions.
2525
- Bi-directional streaming
2626
- High performance async io
2727
- Interoperability
28-
- TLS backed via either [`openssl`] or [`rustls`]
28+
- TLS backed by [`rustls`]
2929
- Load balancing
3030
- Custom metadata
3131
- Authentication
@@ -97,7 +97,6 @@ terms or conditions.
9797
[`prost`]: https://github.com/danburkert/prost
9898
[`protobuf`]: https://developers.google.com/protocol-buffers
9999
[`rustls`]: https://github.com/ctz/rustls
100-
[`openssl`]: https://www.openssl.org/
101100
[`tonic-examples`]: https://github.com/hyperium/tonic/tree/master/tonic-examples
102101
[`tonic-interop`]: https://github.com/hyperium/tonic/tree/master/tonic-interop
103102
[Examples]: https://github.com/hyperium/tonic/tree/master/tonic-examples

tonic-examples/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ name = "gcp-client"
6767
path = "src/gcp/client.rs"
6868

6969
[dependencies]
70-
tonic = { path = "../tonic", features = ["rustls"] }
70+
tonic = { path = "../tonic", features = ["tls"] }
7171
bytes = "0.4"
7272
prost = "0.5"
7373

tonic-interop/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ edition = "2018"
66
publish = false
77
license = "MIT"
88

9-
[features]
10-
default = ["tonic"]
11-
tls_openssl = ["tonic", "tonic/tls", "tonic/openssl"]
12-
tls_rustls = ["tonic", "tonic/tls", "tonic/rustls"]
13-
149
[[bin]]
1510
name = "client"
1611
path = "src/bin/client.rs"
@@ -21,7 +16,7 @@ path = "src/bin/server.rs"
2116

2217
[dependencies]
2318
tokio = "=0.2.0-alpha.6"
24-
tonic = { path = "../tonic", optional = true }
19+
tonic = { path = "../tonic", features = ["tls"] }
2520
prost = "0.5"
2621
prost-derive = "0.5"
2722
bytes = "0.4"

tonic-interop/src/bin/client.rs

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::time::Duration;
22
use structopt::{clap::arg_enum, StructOpt};
33
use tonic::transport::Endpoint;
4-
#[cfg(any(feature = "tls_rustls", feature = "tls_openssl"))]
54
use tonic::transport::{Certificate, ClientTlsConfig};
65
use tonic_interop::client;
76

@@ -33,32 +32,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
3332
.concurrency_limit(30);
3433

3534
if matches.use_tls {
36-
#[cfg(not(any(feature = "tls_rustls", feature = "tls_openssl")))]
37-
{
38-
panic!("No TLS library feature selected");
39-
}
40-
41-
#[cfg(feature = "tls_rustls")]
42-
{
43-
let pem = tokio::fs::read("tonic-interop/data/ca.pem").await?;
44-
let ca = Certificate::from_pem(pem);
45-
endpoint = endpoint.tls_config(
46-
ClientTlsConfig::with_rustls()
47-
.ca_certificate(ca)
48-
.domain_name("foo.test.google.fr"),
49-
);
50-
}
51-
52-
#[cfg(feature = "tls_openssl")]
53-
{
54-
let pem = tokio::fs::read("tonic-interop/data/ca.pem").await?;
55-
let ca = Certificate::from_pem(pem);
56-
endpoint = endpoint.tls_config(
57-
ClientTlsConfig::with_openssl()
58-
.ca_certificate(ca)
59-
.domain_name("foo.test.google.fr"),
60-
);
61-
}
35+
let pem = tokio::fs::read("tonic-interop/data/ca.pem").await?;
36+
let ca = Certificate::from_pem(pem);
37+
endpoint = endpoint.tls_config(
38+
ClientTlsConfig::with_rustls()
39+
.ca_certificate(ca)
40+
.domain_name("foo.test.google.fr"),
41+
);
6242
}
6343

6444
let channel = endpoint.connect().await?;

tonic-interop/src/bin/server.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use structopt::StructOpt;
33
use tonic::body::BoxBody;
44
use tonic::client::GrpcService;
55
use tonic::transport::Server;
6-
#[cfg(any(feature = "tls_rustls", feature = "tls_openssl"))]
76
use tonic::transport::{Identity, ServerTlsConfig};
87
use tonic_interop::{server, MergeTrailers};
98

@@ -50,28 +49,11 @@ async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
5049
});
5150

5251
if matches.use_tls {
53-
#[cfg(not(any(feature = "tls_rustls", feature = "tls_openssl")))]
54-
{
55-
panic!("No TLS library feature selected");
56-
}
57-
58-
#[cfg(feature = "tls_rustls")]
59-
{
60-
let cert = tokio::fs::read("tonic-interop/data/server1.pem").await?;
61-
let key = tokio::fs::read("tonic-interop/data/server1.key").await?;
62-
let identity = Identity::from_pem(cert, key);
63-
64-
builder = builder.tls_config(ServerTlsConfig::with_rustls().identity(identity));
65-
}
66-
67-
#[cfg(feature = "tls_openssl")]
68-
{
69-
let cert = tokio::fs::read("tonic-interop/data/server1.pem").await?;
70-
let key = tokio::fs::read("tonic-interop/data/server1.key").await?;
71-
let identity = Identity::from_pem(cert, key);
52+
let cert = tokio::fs::read("tonic-interop/data/server1.pem").await?;
53+
let key = tokio::fs::read("tonic-interop/data/server1.key").await?;
54+
let identity = Identity::from_pem(cert, key);
7255

73-
builder = builder.tls_config(ServerTlsConfig::with_openssl().identity(identity));
74-
}
56+
builder = builder.tls_config(ServerTlsConfig::with_rustls().identity(identity));
7557
}
7658

7759
let test_service = server::TestServiceServer::new(server::TestService::default());

tonic-interop/test.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,8 @@ case "$OSTYPE" in
1515
esac
1616

1717
ARG="${1:-""}"
18-
TLS_PROVIDER="${2:-""}"
1918

20-
if [[ -n "${TLS_PROVIDER}" ]] ; then
21-
FEATURES="--features ${TLS_PROVIDER}"
22-
else
23-
FEATURES=
24-
fi
25-
26-
(cd tonic-interop && cargo build --bins ${FEATURES})
19+
(cd tonic-interop && cargo build --bins)
2720

2821
SERVER="tonic-interop/bin/server_${OS}_amd64${EXT}"
2922

tonic/Cargo.toml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ transport = [
3232
"tower-balance",
3333
"tower-load",
3434
]
35-
openssl = ["openssl1", "tokio-openssl", "tls"]
36-
rustls = ["tokio-rustls", "tls"]
37-
openssl-roots = ["openssl-probe"]
38-
rustls-roots = ["rustls-native-certs"]
39-
tls = []
35+
tls = ["tokio-rustls"]
36+
tls-roots = ["rustls-native-certs"]
4037

4138
[[bench]]
4239
name = "bench_main"
@@ -72,11 +69,6 @@ tower-make = "=0.3.0-alpha.2a"
7269
tower-balance = { version = "=0.3.0-alpha.2", optional = true }
7370
tower-load = { version = "=0.3.0-alpha.2", optional = true }
7471

75-
# openssl
76-
tokio-openssl = { version = "=0.4.0-alpha.6", optional = true }
77-
openssl1 = { package = "openssl", version = "0.10", optional = true }
78-
openssl-probe = { version = "0.1", optional = true }
79-
8072
# rustls
8173
tokio-rustls = { version = "=0.12.0-alpha.5", optional = true }
8274
rustls-native-certs = { version = "0.1", optional = true }

tonic/src/lib.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,11 @@
2020
//! implementation based on [`hyper`], [`tower`] and [`tokio`]. Enabled by default.
2121
//! - `codegen`: Enables all the required exports and optional dependencies required
2222
//! for [`tonic-build`]. Enabled by default.
23-
//! - `openssl`: Enables the `openssl` based tls options for the `transport` feature`. Not
23+
//! - `tls`: Enables the `ruslts` based TLS options for the `transport` feature`. Not
2424
//! enabled by default.
25-
//! - `openssl-roots`: Adds system trust roots to `openssl`-based gRPC clients using the
26-
//! `openssl-probe` crate. Not enabled by default. `openssl` must be enabled to use
27-
//! `openssl-roots`.
28-
//! - `rustls`: Enables the `ruslts` based tls options for the `transport` feature`. Not
29-
//! enabled by default.
30-
//! - `rustls-roots`: Adds system trust roots to `rustls`-based gRPC clients using the
31-
//! `rustls-native-certs` crate. Not enabled by default. `rustls` must be enabled to use
32-
//! `rustls-roots`.
25+
//! - `tls-roots`: Adds system trust roots to `rustls`-based gRPC clients using the
26+
//! `rustls-native-certs` crate. Not enabled by default. `tls` must be enabled to use
27+
//! `tls-roots`.
3328
//! - `prost`: Enables the [`prost`] based gRPC [`Codec`] implementation.
3429
//!
3530
//! # Structure
@@ -48,8 +43,8 @@
4843
//! and [`Server`]. These implementations are built on top of [`tokio`], [`hyper`] and [`tower`].
4944
//! It also provides many of the features that the core gRPC libraries provide such as load balancing,
5045
//! tls, timeouts, and many more. This implementation can also be used as a reference implementation
51-
//! to build even more feature rich clients and servers. This module also provides the ability to choose
52-
//! between [`rustls`] and [`openssl`] for the tls backend.
46+
//! to build even more feature rich clients and servers. This module also provides the ability to
47+
//! enable TLS using [`rustls`], via the `tls` feature flag.
5348
//!
5449
//! [gRPC]: https://grpc.io
5550
//! [`tonic`]: https://github.com/hyperium/tonic
@@ -63,7 +58,6 @@
6358
//! [`Channel`]: transport/struct.Channel.html
6459
//! [`Server`]: transport/struct.Server.html
6560
//! [`rustls`]: https://docs.rs/rustls
66-
//! [`openssl`]: https://www.openssl.org
6761
//! [`client`]: client/index.html
6862
//! [`transport`]: transport/index.html
6963

0 commit comments

Comments
 (0)