Skip to content

Commit 5d52f91

Browse files
authored
chore: encode jwt key and cert digest with base64 in logs (#2712)
1 parent fddfffc commit 5d52f91

1 file changed

Lines changed: 10 additions & 19 deletions

File tree

src/dist/http.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ mod common {
2424
use reqwest::header;
2525
use serde::{Deserialize, Serialize};
2626
#[cfg(feature = "dist-server")]
27-
use std::collections::HashMap;
27+
use {crate::util::BASE64_URL_SAFE_ENGINE, base64::Engine, std::collections::HashMap};
2828

2929
use crate::dist;
30-
3130
use crate::errors::*;
3231

3332
// Note that content-length is necessary due to https://github.com/tiny-http/tiny-http/issues/147
@@ -154,25 +153,17 @@ mod common {
154153
}
155154

156155
#[cfg(feature = "dist-server")]
157-
// cert_pem is quite long so elide it (you can retrieve it by hitting the server url anyway)
158156
impl std::fmt::Debug for HeartbeatServerHttpRequest {
159157
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
160-
let HeartbeatServerHttpRequest {
161-
jwt_key,
162-
num_cpus,
163-
server_nonce,
164-
cert_digest,
165-
cert_pem,
166-
} = self;
167-
write!(
168-
f,
169-
"HeartbeatServerHttpRequest {{ jwt_key: {:?}, num_cpus: {:?}, server_nonce: {:?}, cert_digest: {:?}, cert_pem: [...{} bytes...] }}",
170-
jwt_key,
171-
num_cpus,
172-
server_nonce,
173-
cert_digest,
174-
cert_pem.len()
175-
)
158+
f.debug_struct("HeartbeatServerHttpRequest")
159+
.field("jwt_key", &BASE64_URL_SAFE_ENGINE.encode(&self.jwt_key))
160+
.field("num_cpus", &self.num_cpus)
161+
.field("server_nonce", &self.server_nonce)
162+
.field(
163+
"cert_digest",
164+
&BASE64_URL_SAFE_ENGINE.encode(&self.cert_digest),
165+
)
166+
.finish()
176167
}
177168
}
178169
#[derive(Clone, Debug, Serialize, Deserialize)]

0 commit comments

Comments
 (0)