fix(certificates): report legacy key password length limit

This commit is contained in:
Kevin Yue committed 2026-11-01 23:35:58 +08:00
1 parent 14c4e24e0e
commit 18ce000640
8 files changed
+92 -76

No files matched your search

@@ -167,6 +167,13 @@ fn decrypt(der: &[u8], passphrase: Option<&str>) -> anyhow::Result<SecretDocumen
// PKCS#12 PBE-SHA1-3DES inside standalone PKCS#8 is not implemented by
// RustCrypto. Only this known legacy scheme uses the native importer.
if algorithm == pkcs8::ObjectIdentifier::new_unwrap("1.2.840.113549.1.12.1.3") {
// Older supported GnuTLS releases allow 256 UTF-16 bytes including the terminator.
if let Some(passphrase) = passphrase {
anyhow::ensure!(
passphrase.encode_utf16().count() <= 127,
"Password is too long for this legacy key format. Re-export the key with modern encryption"
);
}
return certificate::decrypt_key(der, false, passphrase);
}
return Err(RequestIdentityError::UnsupportedEncryption.into());