Skip to content

Commit bb26cdc

Browse files
authored
Introduce meshtls facade to hide rustls crate (#1353)
In #1351, we add an alternate identity/mtls implementation that uses `boring`. To setup for that, this change introduces a new `meshtls` crate that serves as a facade for application crates to depend on, independently of the actual crypto implementation. This change does not change any runtime logic and sets up for #1351 to enable an alternate TLS implementation as a build-time configuration.
1 parent 6e51c64 commit bb26cdc

File tree

28 files changed

+599
-69
lines changed

28 files changed

+599
-69
lines changed

Cargo.lock

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,9 @@ dependencies = [
674674
"linkerd-http-classify",
675675
"linkerd-http-metrics",
676676
"linkerd-http-retry",
677-
"linkerd-identity-default",
677+
"linkerd-identity",
678678
"linkerd-io",
679+
"linkerd-meshtls",
679680
"linkerd-metrics",
680681
"linkerd-opencensus",
681682
"linkerd-proxy-api-resolve",
@@ -743,8 +744,8 @@ dependencies = [
743744
"libfuzzer-sys",
744745
"linkerd-app-core",
745746
"linkerd-app-test",
746-
"linkerd-identity-default",
747747
"linkerd-io",
748+
"linkerd-meshtls-rustls",
748749
"linkerd-server-policy",
749750
"linkerd-tonic-watch",
750751
"linkerd-tracing",
@@ -799,8 +800,8 @@ dependencies = [
799800
"linkerd-app-test",
800801
"linkerd-http-retry",
801802
"linkerd-identity",
802-
"linkerd-identity-default",
803803
"linkerd-io",
804+
"linkerd-meshtls-rustls",
804805
"linkerd-tracing",
805806
"parking_lot",
806807
"pin-project",
@@ -1000,7 +1001,35 @@ dependencies = [
10001001
]
10011002

10021003
[[package]]
1003-
name = "linkerd-identity-default"
1004+
name = "linkerd-io"
1005+
version = "0.1.0"
1006+
dependencies = [
1007+
"async-trait",
1008+
"bytes",
1009+
"futures",
1010+
"linkerd-errno",
1011+
"pin-project",
1012+
"tokio",
1013+
"tokio-test",
1014+
"tokio-util",
1015+
]
1016+
1017+
[[package]]
1018+
name = "linkerd-meshtls"
1019+
version = "0.1.0"
1020+
dependencies = [
1021+
"futures",
1022+
"linkerd-error",
1023+
"linkerd-identity",
1024+
"linkerd-io",
1025+
"linkerd-meshtls-rustls",
1026+
"linkerd-stack",
1027+
"linkerd-tls",
1028+
"pin-project",
1029+
]
1030+
1031+
[[package]]
1032+
name = "linkerd-meshtls-rustls"
10041033
version = "0.1.0"
10051034
dependencies = [
10061035
"futures",
@@ -1022,20 +1051,6 @@ dependencies = [
10221051
"webpki",
10231052
]
10241053

1025-
[[package]]
1026-
name = "linkerd-io"
1027-
version = "0.1.0"
1028-
dependencies = [
1029-
"async-trait",
1030-
"bytes",
1031-
"futures",
1032-
"linkerd-errno",
1033-
"pin-project",
1034-
"tokio",
1035-
"tokio-test",
1036-
"tokio-util",
1037-
]
1038-
10391054
[[package]]
10401055
name = "linkerd-metrics"
10411056
version = "0.1.0"
@@ -1202,8 +1217,8 @@ dependencies = [
12021217
"ipnet",
12031218
"linkerd-conditional",
12041219
"linkerd-error",
1205-
"linkerd-identity-default",
12061220
"linkerd-io",
1221+
"linkerd-meshtls",
12071222
"linkerd-proxy-http",
12081223
"linkerd-stack",
12091224
"linkerd-tls",

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ members = [
2929
"linkerd/http-metrics",
3030
"linkerd/http-retry",
3131
"linkerd/identity",
32-
"linkerd/identity/default",
3332
"linkerd/io",
33+
"linkerd/meshtls",
34+
"linkerd/meshtls/rustls",
3435
"linkerd/metrics",
3536
"linkerd/opencensus",
3637
"linkerd/proxy/api-resolve",

linkerd/app/core/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ This crate conglomerates proxy configuration, runtime administration, etc,
1212
independently of the inbound and outbound proxy logic.
1313
"""
1414

15+
[features]
16+
default = ["meshtls-rustls"]
17+
meshtls-rustls = ["linkerd-meshtls/rustls"]
18+
1519
[dependencies]
1620
bytes = "1"
1721
drain = { version = "0.1.0", features = ["retain"] }
@@ -33,8 +37,9 @@ linkerd-exp-backoff = { path = "../../exp-backoff" }
3337
linkerd-http-classify = { path = "../../http-classify" }
3438
linkerd-http-metrics = { path = "../../http-metrics" }
3539
linkerd-http-retry = { path = "../../http-retry" }
36-
linkerd-identity-default = { path = "../../identity/default" }
40+
linkerd-identity = { path = "../../identity" }
3741
linkerd-io = { path = "../../io" }
42+
linkerd-meshtls = { path = "../../meshtls", default-features = false }
3843
linkerd-metrics = { path = "../../metrics", features = ["linkerd-stack"] }
3944
linkerd-opencensus = { path = "../../opencensus" }
4045
linkerd-proxy-core = { path = "../../proxy/core" }

linkerd/app/core/src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ pub use linkerd_dns;
2020
pub use linkerd_error::{is_error, Error, Infallible, Recover, Result};
2121
pub use linkerd_exp_backoff as exp_backoff;
2222
pub use linkerd_http_metrics as http_metrics;
23-
pub use linkerd_identity_default as identity;
2423
pub use linkerd_io as io;
2524
pub use linkerd_opencensus as opencensus;
26-
pub use linkerd_proxy_identity_client as identity_client;
2725
pub use linkerd_service_profiles as profiles;
2826
pub use linkerd_stack_metrics as stack_metrics;
2927
pub use linkerd_stack_tracing as stack_tracing;
@@ -51,6 +49,12 @@ pub mod transport;
5149

5250
pub use self::addr_match::{AddrMatch, IpMatch, NameMatch};
5351

52+
pub mod identity {
53+
pub use linkerd_identity::*;
54+
pub use linkerd_meshtls::*;
55+
pub use linkerd_proxy_identity_client as client;
56+
}
57+
5458
pub const CANONICAL_DST_HEADER: &str = "l5d-dst-canonical";
5559

5660
const DEFAULT_PORT: u16 = 80;

linkerd/app/inbound/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ libfuzzer-sys = { version = "0.4.2", features = ["arbitrary-derive"] }
3434
hyper = { version = "0.14.14", features = ["http1", "http2"] }
3535
linkerd-app-test = { path = "../test" }
3636
linkerd-io = { path = "../../io", features = ["tokio-test"] }
37-
linkerd-identity-default = { path = "../../identity/default", features = ["test-util"] }
37+
linkerd-meshtls-rustls = { path = "../../meshtls/rustls", features = ["test-util"] }
3838
linkerd-tracing = { path = "../../tracing", features = ["ansi"] }
3939
tokio = { version = "1", features = ["full", "macros"] }
4040
tokio-test = "0.4"

linkerd/app/inbound/fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ libfuzzer-sys = { version = "0.4.2", features = ["arbitrary-derive"] }
1717
linkerd-app-core = { path = "../../core" }
1818
linkerd-app-inbound = { path = ".." }
1919
linkerd-app-test = { path = "../../test" }
20-
linkerd-identity-default = { path = "../../../identity/default", features = ["test-util"] }
20+
linkerd-meshtls-rustls = { path = "../../../meshtls/rustls", features = ["test-util"] }
2121
linkerd-tracing = { path = "../../../tracing", features = ["ansi"] }
2222
tokio = { version = "1", features = ["full"] }
2323
tracing = "0.1"

linkerd/app/inbound/src/test_util.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ pub use futures::prelude::*;
33
use linkerd_app_core::{
44
config,
55
dns::Suffix,
6-
drain, exp_backoff, identity, metrics,
6+
drain, exp_backoff,
7+
identity::rustls,
8+
metrics,
79
proxy::{
810
http::{h1, h2},
911
tap,
@@ -73,7 +75,7 @@ pub fn runtime() -> (ProxyRuntime, drain::Signal) {
7375
let (tap, _) = tap::new();
7476
let (metrics, _) = metrics::Metrics::new(std::time::Duration::from_secs(10));
7577
let runtime = ProxyRuntime {
76-
identity: identity::creds::default_for_test().1,
78+
identity: rustls::creds::default_for_test().1.into(),
7779
metrics: metrics.proxy,
7880
tap,
7981
span_sink: None,

linkerd/app/outbound/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pin-project = "1"
3232
hyper = { version = "0.14.14", features = ["http1", "http2"] }
3333
linkerd-app-test = { path = "../test" }
3434
linkerd-io = { path = "../../io", features = ["tokio-test"] }
35-
linkerd-identity-default = { path = "../../identity/default", features = ["test-util"] }
35+
linkerd-meshtls-rustls = { path = "../../meshtls/rustls", features = ["test-util"] }
3636
linkerd-tracing = { path = "../../tracing", features = ["ansi"] }
3737
parking_lot = "0.11"
3838
tokio = { version = "1", features = ["time", "macros"] }

linkerd/app/outbound/src/test_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::Config;
22
pub use futures::prelude::*;
33
use linkerd_app_core::{
4-
config, drain, exp_backoff, identity, metrics,
4+
config, drain, exp_backoff, metrics,
55
proxy::{
66
http::{h1, h2},
77
tap,
@@ -53,7 +53,7 @@ pub(crate) fn runtime() -> (ProxyRuntime, drain::Signal) {
5353
let (tap, _) = tap::new();
5454
let (metrics, _) = metrics::Metrics::new(std::time::Duration::from_secs(10));
5555
let runtime = ProxyRuntime {
56-
identity: identity::creds::default_for_test().1,
56+
identity: linkerd_meshtls_rustls::creds::default_for_test().1.into(),
5757
metrics: metrics.proxy,
5858
tap,
5959
span_sink: None,

linkerd/app/src/env.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::core::{
22
addr,
33
config::*,
44
control::{Config as ControlConfig, ControlAddr},
5-
identity_client,
65
proxy::http::{h1, h2},
76
tls,
87
transport::{Keepalive, ListenAddr},
@@ -1102,14 +1101,7 @@ pub fn parse_control_addr<S: Strings>(
11021101

11031102
pub fn parse_identity_config<S: Strings>(
11041103
strings: &S,
1105-
) -> Result<
1106-
(
1107-
ControlAddr,
1108-
identity_client::certify::Config,
1109-
identity::Documents,
1110-
),
1111-
EnvError,
1112-
> {
1104+
) -> Result<(ControlAddr, identity::certify::Config, identity::Documents), EnvError> {
11131105
let control = parse_control_addr(strings, ENV_IDENTITY_SVC_BASE);
11141106
let ta = parse(strings, ENV_IDENTITY_TRUST_ANCHORS, |s| {
11151107
if s.is_empty() {

0 commit comments

Comments
 (0)