Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,9 @@ dependencies = [
"linkerd-http-classify",
"linkerd-http-metrics",
"linkerd-http-retry",
"linkerd-identity-default",
"linkerd-identity",
"linkerd-io",
"linkerd-meshtls",
"linkerd-metrics",
"linkerd-opencensus",
"linkerd-proxy-api-resolve",
Expand Down Expand Up @@ -743,8 +744,8 @@ dependencies = [
"libfuzzer-sys",
"linkerd-app-core",
"linkerd-app-test",
"linkerd-identity-default",
"linkerd-io",
"linkerd-meshtls-rustls",
"linkerd-server-policy",
"linkerd-tonic-watch",
"linkerd-tracing",
Expand Down Expand Up @@ -799,8 +800,8 @@ dependencies = [
"linkerd-app-test",
"linkerd-http-retry",
"linkerd-identity",
"linkerd-identity-default",
"linkerd-io",
"linkerd-meshtls-rustls",
"linkerd-tracing",
"parking_lot",
"pin-project",
Expand Down Expand Up @@ -1000,7 +1001,35 @@ dependencies = [
]

[[package]]
name = "linkerd-identity-default"
name = "linkerd-io"
version = "0.1.0"
dependencies = [
"async-trait",
"bytes",
"futures",
"linkerd-errno",
"pin-project",
"tokio",
"tokio-test",
"tokio-util",
]

[[package]]
name = "linkerd-meshtls"
version = "0.1.0"
dependencies = [
"futures",
"linkerd-error",
"linkerd-identity",
"linkerd-io",
"linkerd-meshtls-rustls",
"linkerd-stack",
"linkerd-tls",
"pin-project",
]

[[package]]
name = "linkerd-meshtls-rustls"
version = "0.1.0"
dependencies = [
"futures",
Expand All @@ -1022,20 +1051,6 @@ dependencies = [
"webpki",
]

[[package]]
name = "linkerd-io"
version = "0.1.0"
dependencies = [
"async-trait",
"bytes",
"futures",
"linkerd-errno",
"pin-project",
"tokio",
"tokio-test",
"tokio-util",
]

[[package]]
name = "linkerd-metrics"
version = "0.1.0"
Expand Down Expand Up @@ -1202,8 +1217,8 @@ dependencies = [
"ipnet",
"linkerd-conditional",
"linkerd-error",
"linkerd-identity-default",
"linkerd-io",
"linkerd-meshtls",
"linkerd-proxy-http",
"linkerd-stack",
"linkerd-tls",
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ members = [
"linkerd/http-metrics",
"linkerd/http-retry",
"linkerd/identity",
"linkerd/identity/default",
"linkerd/io",
"linkerd/meshtls",
"linkerd/meshtls/rustls",
"linkerd/metrics",
"linkerd/opencensus",
"linkerd/proxy/api-resolve",
Expand Down
7 changes: 6 additions & 1 deletion linkerd/app/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ This crate conglomerates proxy configuration, runtime administration, etc,
independently of the inbound and outbound proxy logic.
"""

[features]
default = ["meshtls-rustls"]
meshtls-rustls = ["linkerd-meshtls/rustls"]

[dependencies]
bytes = "1"
drain = { version = "0.1.0", features = ["retain"] }
Expand All @@ -33,8 +37,9 @@ linkerd-exp-backoff = { path = "../../exp-backoff" }
linkerd-http-classify = { path = "../../http-classify" }
linkerd-http-metrics = { path = "../../http-metrics" }
linkerd-http-retry = { path = "../../http-retry" }
linkerd-identity-default = { path = "../../identity/default" }
linkerd-identity = { path = "../../identity" }
linkerd-io = { path = "../../io" }
linkerd-meshtls = { path = "../../meshtls", default-features = false }
linkerd-metrics = { path = "../../metrics", features = ["linkerd-stack"] }
linkerd-opencensus = { path = "../../opencensus" }
linkerd-proxy-core = { path = "../../proxy/core" }
Expand Down
8 changes: 6 additions & 2 deletions linkerd/app/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ pub use linkerd_dns;
pub use linkerd_error::{is_error, Error, Infallible, Recover, Result};
pub use linkerd_exp_backoff as exp_backoff;
pub use linkerd_http_metrics as http_metrics;
pub use linkerd_identity_default as identity;
pub use linkerd_io as io;
pub use linkerd_opencensus as opencensus;
pub use linkerd_proxy_identity_client as identity_client;
pub use linkerd_service_profiles as profiles;
pub use linkerd_stack_metrics as stack_metrics;
pub use linkerd_stack_tracing as stack_tracing;
Expand Down Expand Up @@ -51,6 +49,12 @@ pub mod transport;

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

pub mod identity {
pub use linkerd_identity::*;
pub use linkerd_meshtls::*;
pub use linkerd_proxy_identity_client as client;
}

pub const CANONICAL_DST_HEADER: &str = "l5d-dst-canonical";

const DEFAULT_PORT: u16 = 80;
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/inbound/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ libfuzzer-sys = { version = "0.4.2", features = ["arbitrary-derive"] }
hyper = { version = "0.14.14", features = ["http1", "http2"] }
linkerd-app-test = { path = "../test" }
linkerd-io = { path = "../../io", features = ["tokio-test"] }
linkerd-identity-default = { path = "../../identity/default", features = ["test-util"] }
linkerd-meshtls-rustls = { path = "../../meshtls/rustls", features = ["test-util"] }
linkerd-tracing = { path = "../../tracing", features = ["ansi"] }
tokio = { version = "1", features = ["full", "macros"] }
tokio-test = "0.4"
2 changes: 1 addition & 1 deletion linkerd/app/inbound/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ libfuzzer-sys = { version = "0.4.2", features = ["arbitrary-derive"] }
linkerd-app-core = { path = "../../core" }
linkerd-app-inbound = { path = ".." }
linkerd-app-test = { path = "../../test" }
linkerd-identity-default = { path = "../../../identity/default", features = ["test-util"] }
linkerd-meshtls-rustls = { path = "../../../meshtls/rustls", features = ["test-util"] }
linkerd-tracing = { path = "../../../tracing", features = ["ansi"] }
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
Expand Down
6 changes: 4 additions & 2 deletions linkerd/app/inbound/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ pub use futures::prelude::*;
use linkerd_app_core::{
config,
dns::Suffix,
drain, exp_backoff, identity, metrics,
drain, exp_backoff,
identity::rustls,
metrics,
proxy::{
http::{h1, h2},
tap,
Expand Down Expand Up @@ -73,7 +75,7 @@ pub fn runtime() -> (ProxyRuntime, drain::Signal) {
let (tap, _) = tap::new();
let (metrics, _) = metrics::Metrics::new(std::time::Duration::from_secs(10));
let runtime = ProxyRuntime {
identity: identity::creds::default_for_test().1,
identity: rustls::creds::default_for_test().1.into(),
metrics: metrics.proxy,
tap,
span_sink: None,
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/outbound/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pin-project = "1"
hyper = { version = "0.14.14", features = ["http1", "http2"] }
linkerd-app-test = { path = "../test" }
linkerd-io = { path = "../../io", features = ["tokio-test"] }
linkerd-identity-default = { path = "../../identity/default", features = ["test-util"] }
linkerd-meshtls-rustls = { path = "../../meshtls/rustls", features = ["test-util"] }
linkerd-tracing = { path = "../../tracing", features = ["ansi"] }
parking_lot = "0.11"
tokio = { version = "1", features = ["time", "macros"] }
Expand Down
4 changes: 2 additions & 2 deletions linkerd/app/outbound/src/test_util.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::Config;
pub use futures::prelude::*;
use linkerd_app_core::{
config, drain, exp_backoff, identity, metrics,
config, drain, exp_backoff, metrics,
proxy::{
http::{h1, h2},
tap,
Expand Down Expand Up @@ -53,7 +53,7 @@ pub(crate) fn runtime() -> (ProxyRuntime, drain::Signal) {
let (tap, _) = tap::new();
let (metrics, _) = metrics::Metrics::new(std::time::Duration::from_secs(10));
let runtime = ProxyRuntime {
identity: identity::creds::default_for_test().1,
identity: linkerd_meshtls_rustls::creds::default_for_test().1.into(),
metrics: metrics.proxy,
tap,
span_sink: None,
Expand Down
10 changes: 1 addition & 9 deletions linkerd/app/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::core::{
addr,
config::*,
control::{Config as ControlConfig, ControlAddr},
identity_client,
proxy::http::{h1, h2},
tls,
transport::{Keepalive, ListenAddr},
Expand Down Expand Up @@ -1102,14 +1101,7 @@ pub fn parse_control_addr<S: Strings>(

pub fn parse_identity_config<S: Strings>(
strings: &S,
) -> Result<
(
ControlAddr,
identity_client::certify::Config,
identity::Documents,
),
EnvError,
> {
) -> Result<(ControlAddr, identity::certify::Config, identity::Documents), EnvError> {
let control = parse_control_addr(strings, ENV_IDENTITY_SVC_BASE);
let ta = parse(strings, ENV_IDENTITY_TRUST_ANCHORS, |s| {
if s.is_empty() {
Expand Down
16 changes: 9 additions & 7 deletions linkerd/app/src/identity.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
pub use linkerd_app_core::identity::{
client::{certify, TokenSource},
InvalidName, LocalId, Name,
};
use linkerd_app_core::{
control, dns,
exp_backoff::{ExponentialBackoff, ExponentialBackoffStream},
identity::{creds, Credentials, DerX509},
identity_client::{Certify, Metrics as IdentityMetrics},
identity::{
client::{Certify, Metrics as IdentityMetrics},
creds, Credentials, DerX509, Mode,
},
metrics::ControlHttp as ClientMetrics,
Error, Result,
};
pub use linkerd_app_core::{
identity::{InvalidName, LocalId, Name},
identity_client::{certify, TokenSource},
};
use std::{future::Future, pin::Pin};
use tokio::sync::watch;
use tracing::Instrument;
Expand Down Expand Up @@ -53,7 +55,7 @@ struct NotifyReady {

impl Config {
pub fn build(self, dns: dns::Resolver, client_metrics: ClientMetrics) -> Result<Identity> {
let (store, receiver) = creds::watch(
let (store, receiver) = Mode::default().watch(
(*self.documents.id).clone(),
&self.documents.trust_anchors_pem,
&self.documents.key_pkcs8,
Expand Down
22 changes: 22 additions & 0 deletions linkerd/meshtls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "linkerd-meshtls"
version = "0.1.0"
authors = ["Linkerd Developers <cncf-linkerd-dev@lists.cncf.io>"]
license = "Apache-2.0"
edition = "2018"
publish = false

[features]
default = ["rustls"]
rustls = ["linkerd-meshtls-rustls"]


[dependencies]
futures = { version = "0.3", default-features = false }
linkerd-error = { path = "../error" }
linkerd-identity = { path = "../identity" }
linkerd-io = { path = "../io" }
linkerd-meshtls-rustls = { path = "rustls", optional = true }
linkerd-stack = { path = "../stack" }
linkerd-tls = { path = "../tls" }
pin-project = "1"
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "linkerd-identity-default"
name = "linkerd-meshtls-rustls"
version = "0.1.0"
authors = ["Linkerd Developers <cncf-linkerd-dev@lists.cncf.io>"]
license = "Apache-2.0"
Expand All @@ -19,7 +19,7 @@ linkerd-tls = { path = "../../tls" }
linkerd-tls-test-util = { path = "../../tls/test-util", optional = true }
ring = { version = "0.16.19", features = ["std"] }
thiserror = "1"
tokio = { version = "1", features = ["macros", "sync"] }
tokio = { version = "1", features = ["macros", "rt", "sync"] }
tokio-rustls = "0.22"
tracing = "0.1"
webpki = "0.21"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ pub use self::{
client::{ClientIo, Connect, ConnectFuture, NewClient},
server::{Server, ServerIo, TerminateFuture},
};
pub use linkerd_identity::*;
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
use futures::prelude::*;
use linkerd_conditional::Conditional;
use linkerd_error::Infallible;
use linkerd_identity_default::{self as identity, Credentials, DerX509, Name};
use linkerd_identity::{Credentials, DerX509, Name};
use linkerd_io::{self as io, AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use linkerd_meshtls_rustls as meshtls;
use linkerd_proxy_transport::{
addrs::*,
listen::{Addrs, Bind, BindTcp},
Expand All @@ -28,18 +29,12 @@ use tracing::instrument::Instrument;

type ServerConn<T, I> = (
(tls::ConditionalServerTls, T),
io::EitherIo<identity::ServerIo<tls::server::DetectIo<I>>, tls::server::DetectIo<I>>,
io::EitherIo<meshtls::ServerIo<tls::server::DetectIo<I>>, tls::server::DetectIo<I>>,
);

fn load(
ent: &test_util::Entity,
) -> (
identity::creds::Store,
identity::NewClient,
identity::Server,
) {
fn load(ent: &test_util::Entity) -> (meshtls::creds::Store, meshtls::NewClient, meshtls::Server) {
let roots_pem = std::str::from_utf8(ent.trust_anchors).expect("valid PEM");
let (mut store, rx) = identity::creds::watch(
let (mut store, rx) = meshtls::creds::watch(
ent.name.parse().unwrap(),
roots_pem,
ent.key,
Expand Down Expand Up @@ -152,19 +147,19 @@ struct Transported<I, R> {

#[derive(Clone)]
struct ServerParams {
identity: identity::Server,
identity: meshtls::Server,
}

type ClientIo = io::EitherIo<io::ScopedIo<TcpStream>, identity::ClientIo<io::ScopedIo<TcpStream>>>;
type ClientIo = io::EitherIo<io::ScopedIo<TcpStream>, meshtls::ClientIo<io::ScopedIo<TcpStream>>>;

/// Runs a test for a single TCP connection. `client` processes the connection
/// on the client side and `server` processes the connection on the server
/// side.
async fn run_test<C, CF, CR, S, SF, SR>(
client_tls: identity::NewClient,
client_tls: meshtls::NewClient,
client_server_id: Conditional<tls::ServerId, tls::NoClientTls>,
client: C,
server_id: identity::Server,
server_id: meshtls::Server,
server: S,
) -> (
Transported<tls::ConditionalClientTls, CR>,
Expand All @@ -187,7 +182,7 @@ where
// Saves the result of every connection.
let (sender, receiver) = mpsc::channel::<Transported<tls::ConditionalServerTls, SR>>();

let detect = tls::NewDetectTls::<identity::Server, _, _>::new(
let detect = tls::NewDetectTls::<meshtls::Server, _, _>::new(
ServerParams {
identity: server_id,
},
Expand Down Expand Up @@ -375,8 +370,8 @@ impl<T> ExtractParam<tls::server::Timeout, T> for ServerParams {
}
}

impl<T> ExtractParam<identity::Server, T> for ServerParams {
fn extract_param(&self, _: &T) -> identity::Server {
impl<T> ExtractParam<meshtls::Server, T> for ServerParams {
fn extract_param(&self, _: &T) -> meshtls::Server {
self.identity.clone()
}
}
Expand Down
Loading