Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
feat: add custom CA support to the NATS provider, rework Redis TLS
Browse files Browse the repository at this point in the history
This PR does two things:
* adds the ability to add a custom root CA to each NATS linkdef so that
  you can connect to servers that might be secured with self-signed
  certs
* reworks how the Redis provider depends on rustls and other
  dependencies so that the webroot PKI certs are embedded. This removes
  a dependency on the host for anything TLS related.

Signed-off-by: Dan Norris <protochron@users.noreply.github.com>
  • Loading branch information
protochron committed Jan 27, 2024
1 parent 73c9383 commit b30aff3
Show file tree
Hide file tree
Showing 6 changed files with 273 additions and 87 deletions.
105 changes: 80 additions & 25 deletions kvredis/Cargo.lock

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

4 changes: 2 additions & 2 deletions kvredis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wasmcloud-provider-kvredis"
version = "0.22.0"
version = "0.23.0"
edition = "2021"

[dependencies]
Expand All @@ -12,7 +12,7 @@ chrono = "0.4"
crossbeam = "0.8"
futures = "0.3"
once_cell = "1.8"
redis = { version = "0.23.0", features = ["tokio-comp", "aio", "connection-manager", "rustls"] }
redis = { version = "0.24.0", features = ["tokio-rustls-comp", "aio", "connection-manager", "tls-rustls-webpki-roots"] }
rmp-serde = "1.1.0"
serde_bytes = "0.11"
serde_json = "1.0"
Expand Down
21 changes: 12 additions & 9 deletions kvredis/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,17 @@ impl ProviderHandler for KvRedisProvider {
let redis_url = get_redis_url(&ld.values, &self.default_connect_url);

if let Ok(client) = redis::Client::open(redis_url.clone()) {
if let Ok(conn_manager) = client.get_tokio_connection_manager().await {
let mut update_map = self.actors.write().await;
update_map.insert(ld.actor_id.to_string(), RwLock::new(conn_manager));
} else {
warn!(
"Could not create Redis connection manager for actor {}, keyvalue operations will fail",
ld.actor_id
);
match client.get_connection_manager().await {
Ok(conn_manager) => {
let mut update_map = self.actors.write().await;
update_map.insert(ld.actor_id.to_string(), RwLock::new(conn_manager));
}
Err(e) => {
warn!(
"Could not create Redis connection manager for actor {}, keyvalue operations will fail: {}",
ld.actor_id, e
);
}
}
} else {
warn!(
Expand Down Expand Up @@ -245,7 +248,7 @@ impl KeyValue for KvRedisProvider {
async fn set(&self, ctx: &Context, arg: &SetRequest) -> RpcResult<()> {
let mut cmd = match arg.expires {
0 => redis::Cmd::set(&arg.key, &arg.value),
_ => redis::Cmd::set_ex(&arg.key, &arg.value, arg.expires as usize),
_ => redis::Cmd::set_ex(&arg.key, &arg.value, arg.expires as u64),
};
let _value: Option<String> = self.exec(ctx, &mut cmd).await?;
Ok(())
Expand Down
Loading

0 comments on commit b30aff3

Please sign in to comment.