Skip to content

Commit 3f482d9

Browse files
lvkvcpu
authored andcommitted
Elide private key in KeyPair Debug impl
1 parent 611340f commit 3f482d9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

rcgen/src/key_pair.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,22 @@ impl fmt::Debug for KeyPairKind {
6464
/// `openssl genrsa` doesn't work. See ring's [documentation](ring::signature::RsaKeyPair::from_pkcs8)
6565
/// for how to generate RSA keys in the wanted format
6666
/// and conversion between the formats.
67-
#[derive(Debug)]
6867
pub struct KeyPair {
6968
pub(crate) kind: KeyPairKind,
7069
pub(crate) alg: &'static SignatureAlgorithm,
7170
pub(crate) serialized_der: Vec<u8>,
7271
}
7372

73+
impl fmt::Debug for KeyPair {
74+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
75+
f.debug_struct("KeyPair")
76+
.field("kind", &self.kind)
77+
.field("alg", &self.alg)
78+
.field("serialized_der", &"[secret key elided]")
79+
.finish()
80+
}
81+
}
82+
7483
impl KeyPair {
7584
/// Generate a new random [`PKCS_ECDSA_P256_SHA256`] key pair
7685
#[cfg(feature = "crypto")]

0 commit comments

Comments
 (0)