Skip to content

Commit 89572f7

Browse files
committed
Take cert_der by reference in fetch_ohttp_keys_with_cert
The cert_der parameter is only passed to Certificate::from_der which borrows it, so accept &[u8] instead of Vec<u8>. Fix call sites in payjoin-cli and payjoin-test-utils accordingly. Other pub fns in io.rs and ohttp.rs keep ownership where consumed (ohttp_context, impl IntoUrl).
1 parent 891711e commit 89572f7

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

payjoin-cli/src/app/v2/ohttp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async fn fetch_ohttp_keys(
8585
payjoin::io::fetch_ohttp_keys_with_cert(
8686
selected_relay.as_str(),
8787
payjoin_directory.as_str(),
88-
cert_der,
88+
&cert_der,
8989
)
9090
.await
9191
} else {

payjoin-test-utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl TestServices {
103103
fetch_ohttp_keys_with_cert(
104104
self.ohttp_relay_url().as_str(),
105105
self.directory_url().as_str(),
106-
self.cert(),
106+
&self.cert(),
107107
)
108108
.await
109109
}

payjoin/src/core/io.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ pub async fn fetch_ohttp_keys(
4545
pub async fn fetch_ohttp_keys_with_cert(
4646
ohttp_relay: impl IntoUrl,
4747
payjoin_directory: impl IntoUrl,
48-
cert_der: Vec<u8>,
48+
cert_der: &[u8],
4949
) -> Result<OhttpKeys, Error> {
5050
let ohttp_keys_url = payjoin_directory.into_url()?.join("/.well-known/ohttp-gateway")?;
5151
let proxy = Proxy::all(ohttp_relay.into_url()?.as_str())?;
5252
let client = Client::builder()
5353
.use_rustls_tls()
54-
.add_root_certificate(reqwest::tls::Certificate::from_der(&cert_der)?)
54+
.add_root_certificate(reqwest::tls::Certificate::from_der(cert_der)?)
5555
.proxy(proxy)
5656
.http1_only()
5757
.build()?;

0 commit comments

Comments
 (0)