Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Initialize rustls's CryptoProvider early in the code #2312

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion rust/numaflow-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ edition = "2021"
[features]
nats-tests = []
pulsar-tests = []
all-tests = ["nats-tests", "pulsar-tests"]
redis-tests = []
all-tests = ["nats-tests", "pulsar-tests", "redis-tests"]

[lints]
workspace = true
Expand Down
5 changes: 5 additions & 0 deletions rust/numaflow-core/src/source/serving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,18 @@ mod tests {
}
}

#[cfg(feature = "redis-tests")]
#[tokio::test]
async fn test_serving_source_reader_acker() -> Result<()> {
let settings = Settings {
app_listen_port: 2000,
..Default::default()
};
let settings = Arc::new(settings);
// Setup the CryptoProvider (controls core cryptography used by rustls) for the process
// ServingSource starts an Axum HTTPS server in the background. Rustls is used to generate
// self-signed certs when starting the server.
let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();
let mut serving_source = ServingSource::new(
Arc::clone(&settings),
10,
Expand Down
1 change: 1 addition & 0 deletions rust/numaflow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ numaflow-models.workspace = true
backoff.workspace = true
tokio.workspace = true
tracing.workspace = true
rustls.workspace = true
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
6 changes: 6 additions & 0 deletions rust/numaflow/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ async fn main() -> Result<(), Box<dyn Error>> {
)
.with(tracing_subscriber::fmt::layer().with_ansi(false))
.init();

// Setup the CryptoProvider (controls core cryptography used by rustls) for the process
rustls::crypto::aws_lc_rs::default_provider()
.install_default()
.expect("Installing default CryptoProvider");

if let Err(e) = run().await {
error!("{e:?}");
return Err(e);
Expand Down
6 changes: 0 additions & 6 deletions rust/serving/src/app/jetstream_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ use crate::{app::callback::state, Message, MessageWrapper};
// "from_vertex": "a"
// }

const CALLBACK_URL_KEY: &str = "X-Numaflow-Callback-Url";
const NUMAFLOW_RESP_ARRAY_LEN: &str = "Numaflow-Array-Len";
const NUMAFLOW_RESP_ARRAY_IDX_LEN: &str = "Numaflow-Array-Index-Len";

struct ProxyState<T> {
message: mpsc::Sender<MessageWrapper>,
tid_header: String,
callback: state::State<T>,
callback_url: String,
}

pub(crate) async fn jetstream_proxy<T: Clone + Send + Sync + Store + 'static>(
Expand All @@ -50,10 +48,6 @@ pub(crate) async fn jetstream_proxy<T: Clone + Send + Sync + Store + 'static>(
message: state.message.clone(),
tid_header: state.settings.tid_header.clone(),
callback: state.callback_state.clone(),
callback_url: format!(
"https://{}:{}/v1/process/callback",
state.settings.host_ip, state.settings.app_listen_port
),
});

let router = Router::new()
Expand Down
3 changes: 0 additions & 3 deletions rust/serving/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ pub(crate) async fn serve<T>(
where
T: Clone + Send + Sync + Store + 'static,
{
// Setup the CryptoProvider (controls core cryptography used by rustls) for the process
let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();

let (cert, key) = generate_certs()?;

let tls_config = RustlsConfig::from_pem(cert.pem().into(), key.serialize_pem().into())
Expand Down
2 changes: 1 addition & 1 deletion rust/serving/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(crate) struct Edge {
/// DCG (directed compute graph) of the pipeline with minimal information build using vertices and edges
/// from the pipeline spec
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq)]
pub(crate) struct PipelineDCG {
pub struct PipelineDCG {
pub(crate) vertices: Vec<Vertex>,
pub(crate) edges: Vec<Edge>,
}
Expand Down
Loading