mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
feat: add connection dashboard and improve desktop authentication
Add tunnel configuration reporting, an optional CLI dashboard, manual browser authentication, native authentication controls, and broader client identity support. Improve TLS recovery, certificate validation, desktop notifications, and platform integration.
This commit is contained in:
158 files changed
+13735
-1038
No files matched your search
+10
-5
@@ -13,9 +13,10 @@ base64.workspace = true
|
||||
dns-lookup.workspace = true
|
||||
log.workspace = true
|
||||
reqwest.workspace = true
|
||||
openssl.workspace = true
|
||||
version-compare = "0.2"
|
||||
native-tls = "0.2"
|
||||
pem.workspace = true
|
||||
pkcs8 = { version = "0.11", features = ["pem", "encryption", "sha1-insecure", "3des", "des-insecure"] }
|
||||
x509-cert = { version = "0.3", default-features = false }
|
||||
xmltree.workspace = true
|
||||
serde.workspace = true
|
||||
specta = { workspace = true, features = ["derive", "uuid"] }
|
||||
@@ -27,14 +28,12 @@ whoami.workspace = true
|
||||
tempfile.workspace = true
|
||||
thiserror.workspace = true
|
||||
chacha20poly1305 = { version = "0.11", features = ["zeroize"] }
|
||||
redact-engine.workspace = true
|
||||
url.workspace = true
|
||||
regex.workspace = true
|
||||
uzers.workspace = true
|
||||
serde_urlencoded.workspace = true
|
||||
md5.workspace = true
|
||||
sha256.workspace = true
|
||||
sha2 = { version = "0.11", default-features = false }
|
||||
sha2.workspace = true
|
||||
uuid = { workspace = true, features = ["v4", "v5", "serde"] }
|
||||
chrono.workspace = true
|
||||
humantime.workspace = true
|
||||
@@ -54,13 +53,19 @@ env_logger = { workspace = true, optional = true }
|
||||
log-reload = { version = "0.1", optional = true }
|
||||
|
||||
[target.'cfg(target_os="macos")'.dependencies]
|
||||
security-framework = "3"
|
||||
oslog = { version = "0.2", default-features = false, optional = true }
|
||||
|
||||
# Dependencies for Linux and other OSes only
|
||||
[target.'cfg(not(any(target_os="macos", target_os="windows")))'.dependencies]
|
||||
gtk = { version = "0.18", optional = true }
|
||||
|
||||
[target.'cfg(not(target_os = "macos"))'.dependencies]
|
||||
openssl.workspace = true
|
||||
version-compare = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
openssl.workspace = true
|
||||
proptest.workspace = true
|
||||
tokio = { workspace = true, features = ["test-util"] }
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ pub enum SamlAuthResult {
|
||||
Success(SamlAuthData),
|
||||
Cancelled,
|
||||
Failure(String),
|
||||
ServerTlsError(crate::error::ServerTlsError),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -68,6 +69,7 @@ impl SamlAuthResult {
|
||||
SamlAuthResult::Success(_) => true,
|
||||
SamlAuthResult::Cancelled => false,
|
||||
SamlAuthResult::Failure(_) => false,
|
||||
SamlAuthResult::ServerTlsError(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +78,7 @@ impl SamlAuthResult {
|
||||
SamlAuthResult::Success(auth_data) => auth_data.host_id(),
|
||||
SamlAuthResult::Cancelled => None,
|
||||
SamlAuthResult::Failure(_) => None,
|
||||
SamlAuthResult::ServerTlsError(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,14 @@ use clap_verbosity_flag::{LogLevel, Verbosity, VerbosityFilter};
|
||||
use log::Level;
|
||||
|
||||
use crate::{
|
||||
error::PortalError,
|
||||
error::ServerTlsErrorKind,
|
||||
log_format::{LogFormat, write_json_record},
|
||||
};
|
||||
|
||||
pub mod args;
|
||||
|
||||
pub trait Args {
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn fix_openssl(&self) -> bool;
|
||||
fn ignore_tls_errors(&self) -> bool;
|
||||
|
||||
@@ -26,7 +27,7 @@ pub trait Args {
|
||||
/// workaround. Empty when there is nothing useful to say — including when the
|
||||
/// relevant option is already in use.
|
||||
fn retry_hints(err: &anyhow::Error, args: &impl Args) -> Vec<String> {
|
||||
let Some(err) = err.downcast_ref::<PortalError>() else {
|
||||
let Some(kind) = ServerTlsErrorKind::from_error(err) else {
|
||||
return Vec::new();
|
||||
};
|
||||
|
||||
@@ -42,14 +43,15 @@ fn retry_hints(err: &anyhow::Error, args: &impl Args) -> Vec<String> {
|
||||
// users already see; keep it exactly.
|
||||
let mut hints = Vec::new();
|
||||
|
||||
if err.is_legacy_openssl_error() && !args.fix_openssl() {
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
if kind == ServerTlsErrorKind::LegacyRenegotiation && !args.fix_openssl() {
|
||||
let (program, rest) = command_line();
|
||||
hints.push(format!(
|
||||
"Re-run it with the `--fix-openssl` option to work around this issue, e.g.:\n\n{program} --fix-openssl {rest}"
|
||||
));
|
||||
}
|
||||
|
||||
if err.is_tls_error() && !args.ignore_tls_errors() {
|
||||
if kind == ServerTlsErrorKind::Certificate && !args.ignore_tls_errors() {
|
||||
let (program, rest) = command_line();
|
||||
hints.push(format!(
|
||||
"Re-run it with the `--ignore-tls-errors` option to ignore the certificate error, e.g.:\n\n{program} --ignore-tls-errors {rest}"
|
||||
@@ -191,15 +193,25 @@ mod tests {
|
||||
use anyhow::anyhow;
|
||||
|
||||
use super::*;
|
||||
use crate::error::ServerTlsError;
|
||||
|
||||
fn certificate_error() -> ServerTlsError {
|
||||
ServerTlsError {
|
||||
server: "https://vpn.example.com".into(),
|
||||
kind: ServerTlsErrorKind::Certificate,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct TestArgs {
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fix_openssl: bool,
|
||||
ignore_tls_errors: bool,
|
||||
log_format: LogFormat,
|
||||
}
|
||||
|
||||
impl Args for TestArgs {
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn fix_openssl(&self) -> bool {
|
||||
self.fix_openssl
|
||||
}
|
||||
@@ -224,7 +236,7 @@ mod tests {
|
||||
};
|
||||
let mut out = Vec::new();
|
||||
|
||||
handle_error_to(&mut out, anyhow!(PortalError::TlsError), &args).expect("writing to a Vec cannot fail");
|
||||
handle_error_to(&mut out, anyhow!(certificate_error()), &args).expect("writing to a Vec cannot fail");
|
||||
|
||||
let out = String::from_utf8(out).expect("output should be UTF-8");
|
||||
for line in out.lines() {
|
||||
@@ -235,7 +247,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn a_tls_failure_suggests_ignoring_tls_errors() {
|
||||
let hints = retry_hints(&anyhow!(PortalError::TlsError), &TestArgs::default());
|
||||
let hints = retry_hints(&anyhow!(certificate_error()), &TestArgs::default());
|
||||
|
||||
assert_eq!(hints.len(), 1, "expected one hint, got {hints:?}");
|
||||
assert!(hints[0].contains("--ignore-tls-errors"), "got {:?}", hints[0]);
|
||||
@@ -247,6 +259,34 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hints_distinguish_legacy_and_unknown_tls_and_respect_both_flags() {
|
||||
let legacy = ServerTlsError {
|
||||
server: "https://vpn.example.com".into(),
|
||||
kind: ServerTlsErrorKind::LegacyRenegotiation,
|
||||
};
|
||||
let hints = retry_hints(&anyhow!(legacy.clone()), &TestArgs::default());
|
||||
if cfg!(target_os = "macos") {
|
||||
assert!(hints.is_empty());
|
||||
} else {
|
||||
assert_eq!(hints.len(), 1);
|
||||
assert!(hints[0].contains("--fix-openssl"));
|
||||
}
|
||||
let args = TestArgs {
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fix_openssl: true,
|
||||
ignore_tls_errors: true,
|
||||
..Default::default()
|
||||
};
|
||||
assert!(retry_hints(&anyhow!(legacy), &args).is_empty());
|
||||
assert!(retry_hints(&anyhow!(certificate_error()), &args).is_empty());
|
||||
let other = ServerTlsError {
|
||||
server: "https://vpn.example.com".into(),
|
||||
kind: ServerTlsErrorKind::Other,
|
||||
};
|
||||
assert!(retry_hints(&anyhow!(other), &TestArgs::default()).is_empty());
|
||||
}
|
||||
|
||||
/// Suggesting an option the user already passed is noise, and in JSON mode it
|
||||
/// would be an extra record on every failed run.
|
||||
#[test]
|
||||
@@ -256,7 +296,7 @@ mod tests {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
assert!(retry_hints(&anyhow!(PortalError::TlsError), &args).is_empty());
|
||||
assert!(retry_hints(&anyhow!(certificate_error()), &args).is_empty());
|
||||
}
|
||||
|
||||
/// Most failures have no known workaround; inventing advice for them would
|
||||
@@ -272,7 +312,7 @@ mod tests {
|
||||
let hints = vec!["Re-run it with the `--ignore-tls-errors` option".to_string()];
|
||||
let mut out = Vec::new();
|
||||
|
||||
write_failure(&mut out, format, &anyhow!(PortalError::TlsError), &hints).expect("writing to a Vec cannot fail");
|
||||
write_failure(&mut out, format, &anyhow!(certificate_error()), &hints).expect("writing to a Vec cannot fail");
|
||||
|
||||
String::from_utf8(out).expect("output should be UTF-8")
|
||||
}
|
||||
|
||||
@@ -252,6 +252,7 @@ impl TryFrom<SamlAuthResult> for Credential {
|
||||
SamlAuthResult::Success(auth_data) => Ok(Self::from(auth_data)),
|
||||
SamlAuthResult::Cancelled => bail!(AuthenticationCancelled),
|
||||
SamlAuthResult::Failure(err) => bail!(err),
|
||||
SamlAuthResult::ServerTlsError(err) => Err(err.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
use thiserror::Error;
|
||||
|
||||
mod server_tls;
|
||||
pub use server_tls::{ServerTlsError, ServerTlsErrorKind};
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum PortalError {
|
||||
#[error("Prelogin error: {0}")]
|
||||
@@ -10,18 +13,14 @@ pub enum PortalError {
|
||||
|
||||
#[error(transparent)]
|
||||
NetworkError(#[from] reqwest::Error),
|
||||
|
||||
#[error("TLS error")]
|
||||
TlsError,
|
||||
}
|
||||
|
||||
impl PortalError {
|
||||
pub fn is_legacy_openssl_error(&self) -> bool {
|
||||
format!("{:?}", self).contains("unsafe legacy renegotiation")
|
||||
}
|
||||
|
||||
pub fn is_tls_error(&self) -> bool {
|
||||
matches!(self, PortalError::TlsError) || format!("{:?}", self).contains("certificate verify failed")
|
||||
fn tls_error_kind(&self) -> Option<ServerTlsErrorKind> {
|
||||
match self {
|
||||
Self::NetworkError(error) => server_tls::classify(error),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,515 @@
|
||||
use std::{error::Error, fmt};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::PortalError;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[path = "server_tls/macos.rs"]
|
||||
mod backend;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[path = "server_tls/openssl.rs"]
|
||||
mod backend;
|
||||
|
||||
/// A VPN HTTP TLS failure. The server identifies the configured VPN origin,
|
||||
/// not necessarily the peer that failed after an HTTP redirect.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ServerTlsError {
|
||||
pub server: String,
|
||||
pub kind: ServerTlsErrorKind,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum ServerTlsErrorKind {
|
||||
Certificate,
|
||||
ClientCertificateRequired,
|
||||
LegacyRenegotiation,
|
||||
Other,
|
||||
}
|
||||
|
||||
impl ServerTlsError {
|
||||
pub(crate) fn from_request(server: &url::Url, error: &(dyn Error + 'static)) -> Option<Self> {
|
||||
Some(Self {
|
||||
server: server.origin().ascii_serialization(),
|
||||
kind: classify(error)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ServerTlsError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let message = match self.kind {
|
||||
ServerTlsErrorKind::Certificate => "The server's certificate could not be verified",
|
||||
ServerTlsErrorKind::ClientCertificateRequired => "The server requires a client certificate",
|
||||
ServerTlsErrorKind::LegacyRenegotiation => "The server requires unsafe legacy TLS renegotiation",
|
||||
ServerTlsErrorKind::Other => "A secure connection to the server could not be established",
|
||||
};
|
||||
write!(f, "{message}: {}", self.server)
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for ServerTlsError {}
|
||||
|
||||
impl ServerTlsErrorKind {
|
||||
/// One classification interface for CLI hints and desktop error mapping.
|
||||
pub fn from_error(error: &anyhow::Error) -> Option<Self> {
|
||||
error.chain().find_map(|source| {
|
||||
source
|
||||
.downcast_ref::<ServerTlsError>()
|
||||
.map(|error| error.kind)
|
||||
.or_else(|| {
|
||||
source
|
||||
.downcast_ref::<PortalError>()
|
||||
.and_then(PortalError::tls_error_kind)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn classify(error: &(dyn Error + 'static)) -> Option<ServerTlsErrorKind> {
|
||||
let mut source = Some(error);
|
||||
let mut fallback = None;
|
||||
while let Some(error) = source {
|
||||
if let Some(tls) = error.downcast_ref::<ServerTlsError>() {
|
||||
return Some(tls.kind);
|
||||
}
|
||||
if let Some(kind) = backend::classify(error) {
|
||||
return Some(kind);
|
||||
}
|
||||
if let Some(tls) = error.downcast_ref::<native_tls::Error>() {
|
||||
let kind = classify_native(tls);
|
||||
if kind != ServerTlsErrorKind::Other {
|
||||
return Some(kind);
|
||||
}
|
||||
fallback = Some(kind);
|
||||
}
|
||||
source = error
|
||||
.downcast_ref::<std::io::Error>()
|
||||
.and_then(|error| error.get_ref().map(|inner| inner as &(dyn Error + 'static)))
|
||||
.or_else(|| error.source());
|
||||
}
|
||||
fallback
|
||||
}
|
||||
|
||||
fn classify_native(error: &native_tls::Error) -> ServerTlsErrorKind {
|
||||
// native-tls hides some backend reason codes and verification results. Keep
|
||||
// backend text matching here, scoped to a confirmed native TLS error.
|
||||
let detail = format!("{error:?}").to_ascii_lowercase();
|
||||
classify_native_detail(&detail)
|
||||
}
|
||||
|
||||
fn classify_native_detail(detail: &str) -> ServerTlsErrorKind {
|
||||
// native-tls forwards Security.framework's Debug representation, but hides
|
||||
// its OSStatus from the public error chain. Prefer that status to localized
|
||||
// text, including for peer alerts that can mention a rejected client cert.
|
||||
if let Some(code) = detail
|
||||
.strip_prefix("error { code: ")
|
||||
.and_then(|detail| detail.split_once(','))
|
||||
.and_then(|(code, _)| code.parse::<i32>().ok())
|
||||
{
|
||||
return classify_macos_status(code);
|
||||
}
|
||||
if detail.contains("unsafe legacy renegotiation") {
|
||||
return ServerTlsErrorKind::LegacyRenegotiation;
|
||||
}
|
||||
if detail.contains("alert certificate required") {
|
||||
return ServerTlsErrorKind::ClientCertificateRequired;
|
||||
}
|
||||
let certificate = [
|
||||
"certificate verify failed",
|
||||
"certificate verification failed",
|
||||
"certificate was not trusted",
|
||||
"certificate is not trusted",
|
||||
"self signed certificate",
|
||||
"hostname mismatch",
|
||||
"certificate has expired",
|
||||
"certificate is not yet valid",
|
||||
"certificate has been revoked",
|
||||
]
|
||||
.iter()
|
||||
.any(|reason| detail.contains(reason));
|
||||
if certificate {
|
||||
ServerTlsErrorKind::Certificate
|
||||
} else {
|
||||
ServerTlsErrorKind::Other
|
||||
}
|
||||
}
|
||||
|
||||
fn classify_macos_status(code: i32) -> ServerTlsErrorKind {
|
||||
if code == -9863 {
|
||||
return ServerTlsErrorKind::ClientCertificateRequired;
|
||||
}
|
||||
// Local server-certificate validation failures from Security/SecBase.h.
|
||||
// Peer alerts (errSSLPeer*) reject our client certificate; protocol/cipher,
|
||||
// keychain, and internal errors also cannot be fixed by skipping server trust.
|
||||
let certificate = matches!(
|
||||
code,
|
||||
-9807 // errSSLXCertChainInvalid
|
||||
| -9812 // errSSLUnknownRootCert
|
||||
| -9813 // errSSLNoRootCert
|
||||
| -9814 // errSSLCertExpired
|
||||
| -9815 // errSSLCertNotYetValid
|
||||
| -9843 // errSSLHostNameMismatch
|
||||
| -9884 // errSSLATSLeafCertificateHashAlgorithmViolation
|
||||
| -9885 // errSSLATSCertificateHashAlgorithmViolation
|
||||
| -9886 // errSSLATSCertificateTrustViolation
|
||||
| -67602 // errSecHostNameMismatch
|
||||
| -67603 // errSecUnknownCriticalExtensionFlag
|
||||
| -67604 // errSecNoBasicConstraints
|
||||
| -67605 // errSecNoBasicConstraintsCA
|
||||
| -67606 // errSecInvalidAuthorityKeyID
|
||||
| -67607 // errSecInvalidSubjectKeyID
|
||||
| -67608 // errSecInvalidKeyUsageForPolicy
|
||||
| -67609 // errSecInvalidExtendedKeyUsage
|
||||
| -67610 // errSecInvalidIDLinkage
|
||||
| -67611 // errSecPathLengthConstraintExceeded
|
||||
| -67612 // errSecInvalidRoot
|
||||
| -67629 // errSecSSLBadExtendedKeyUsage
|
||||
| -67654 // errSecTrustSettingDeny
|
||||
| -67818 // errSecCertificateExpired
|
||||
| -67819 // errSecCertificateNotValidYet
|
||||
| -67820 // errSecCertificateRevoked
|
||||
| -67821 // errSecCertificateSuspended
|
||||
| -67826 // errSecInvalidCertAuthority
|
||||
| -67843 // errSecNotTrusted
|
||||
| -67899 // errSecCertificatePolicyNotAllowed
|
||||
| -67900 // errSecCertificateNameNotAllowed
|
||||
| -67901 // errSecCertificateValidityPeriodTooLong
|
||||
| -67902 // errSecCertificateIsCA
|
||||
| -67903 // errSecCertificateDuplicateExtension
|
||||
| -67904 // errSecMissingQualifiedCertStatement
|
||||
);
|
||||
if certificate {
|
||||
ServerTlsErrorKind::Certificate
|
||||
} else {
|
||||
ServerTlsErrorKind::Other
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use openssl::{
|
||||
asn1::Asn1Time,
|
||||
hash::MessageDigest,
|
||||
pkey::PKey,
|
||||
rsa::Rsa,
|
||||
ssl::{SslAcceptor, SslMethod, SslVerifyMode},
|
||||
x509::{X509, X509NameBuilder},
|
||||
};
|
||||
use std::{
|
||||
io::{Read, Write},
|
||||
net::TcpListener,
|
||||
thread,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn explicit_client_certificate_requirement_has_a_distinct_kind() {
|
||||
let kind = classify_native_detail("error { code: -9863, message: \"localized message\" }");
|
||||
assert_eq!(serde_json::to_value(kind).unwrap(), "clientCertificateRequired");
|
||||
assert_eq!(
|
||||
classify_native_detail("error { code: -9842, message: \"client cert requested\" }"),
|
||||
ServerTlsErrorKind::Other
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn macos_certificate_statuses_do_not_depend_on_the_error_message() {
|
||||
for code in [-67818, -67819, -67820, -67843, -67602, -67629, -67899, -67901] {
|
||||
let detail = format!("error {{ code: {code}, message: \"localized message\" }}");
|
||||
assert_eq!(
|
||||
classify_native_detail(&detail),
|
||||
ServerTlsErrorKind::Certificate,
|
||||
"{code}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn macos_peer_alerts_and_handshake_errors_are_not_certificate_validation_failures() {
|
||||
for (code, message) in [
|
||||
(-9800, "SSL protocol error"),
|
||||
(-9801, "Cipher Suite negotiation failure"),
|
||||
(-9828, "peer certificate has expired"),
|
||||
(-9831, "unknown certificate authority"),
|
||||
(-9850, "weak ephemeral DH key"),
|
||||
] {
|
||||
let detail = format!("error {{ code: {code}, message: \"{message}\" }}").to_ascii_lowercase();
|
||||
assert_eq!(classify_native_detail(&detail), ServerTlsErrorKind::Other, "{code}");
|
||||
}
|
||||
}
|
||||
|
||||
fn server(tls: bool) -> (String, thread::JoinHandle<()>) {
|
||||
server_with_client_auth(tls, SslVerifyMode::NONE)
|
||||
}
|
||||
|
||||
fn server_with_client_auth(tls: bool, verify: SslVerifyMode) -> (String, thread::JoinHandle<()>) {
|
||||
let key = PKey::from_rsa(Rsa::generate(2048).unwrap()).unwrap();
|
||||
let mut name = X509NameBuilder::new().unwrap();
|
||||
name.append_entry_by_text("CN", "localhost").unwrap();
|
||||
let name = name.build();
|
||||
let mut cert = X509::builder().unwrap();
|
||||
cert.set_version(2).unwrap();
|
||||
cert.set_subject_name(&name).unwrap();
|
||||
cert.set_issuer_name(&name).unwrap();
|
||||
cert.set_pubkey(&key).unwrap();
|
||||
cert.set_not_before(&Asn1Time::days_from_now(0).unwrap()).unwrap();
|
||||
cert.set_not_after(&Asn1Time::days_from_now(1).unwrap()).unwrap();
|
||||
cert.sign(&key, MessageDigest::sha256()).unwrap();
|
||||
let mut acceptor = SslAcceptor::mozilla_intermediate_v5(SslMethod::tls()).unwrap();
|
||||
acceptor.set_private_key(&key).unwrap();
|
||||
acceptor.set_certificate(&cert.build()).unwrap();
|
||||
acceptor.set_verify(verify);
|
||||
acceptor
|
||||
.set_ca_file(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/tests/files/client-identity/root.pem"
|
||||
))
|
||||
.unwrap();
|
||||
let acceptor = acceptor.build();
|
||||
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let address = format!("https://{}", listener.local_addr().unwrap());
|
||||
let worker = thread::spawn(move || {
|
||||
let (mut stream, _) = listener.accept().unwrap();
|
||||
stream.set_read_timeout(Some(Duration::from_secs(5))).unwrap();
|
||||
stream.set_write_timeout(Some(Duration::from_secs(5))).unwrap();
|
||||
let body = "<prelogin-response><status>Success</status><saml-auth-method>REDIRECT</saml-auth-method><saml-request>aHR0cHM6Ly9pZHAuZXhhbXBsZS5jb20v</saml-request></prelogin-response>";
|
||||
let response = format!(
|
||||
"HTTP/1.1 200 OK\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}",
|
||||
body.len()
|
||||
);
|
||||
let mut request = [0; 8192];
|
||||
if tls {
|
||||
if let Ok(mut stream) = acceptor.accept(stream) {
|
||||
let _ = stream.read(&mut request);
|
||||
let _ = stream.write_all(response.as_bytes());
|
||||
}
|
||||
} else {
|
||||
let _ = stream.read(&mut request);
|
||||
let _ = stream.write_all(response.as_bytes());
|
||||
}
|
||||
});
|
||||
(address, worker)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn prelogin_returns_typed_certificate_failure_with_only_the_server_origin() {
|
||||
use crate::{
|
||||
gp_params::GpParams,
|
||||
os_profile::{ClientOs, OsProfile},
|
||||
portal::{PreloginOptions, prelogin},
|
||||
};
|
||||
let (address, worker) = server(true);
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let params = GpParams::builder(profile).build();
|
||||
let error = prelogin(&address, ¶ms, PreloginOptions::default())
|
||||
.await
|
||||
.unwrap_err();
|
||||
worker.join().unwrap();
|
||||
let tls = error
|
||||
.downcast_ref::<ServerTlsError>()
|
||||
.unwrap_or_else(|| panic!("unclassified: {error:?}"));
|
||||
assert_eq!(tls.kind, ServerTlsErrorKind::Certificate);
|
||||
assert_eq!(tls.server, address);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn certificate_bypass_allows_prelogin() {
|
||||
use crate::{
|
||||
gp_params::GpParams,
|
||||
os_profile::{ClientOs, OsProfile},
|
||||
portal::{PreloginOptions, prelogin},
|
||||
};
|
||||
let (address, worker) = server(true);
|
||||
let params = GpParams::builder(OsProfile::builder(ClientOs::Linux).build())
|
||||
.ignore_tls_errors(true)
|
||||
.build();
|
||||
let result = prelogin(&address, ¶ms, PreloginOptions::default()).await;
|
||||
worker.join().unwrap();
|
||||
assert!(matches!(result.unwrap(), crate::portal::Prelogin::Saml(_)));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn incompatible_tls_is_not_a_certificate_error_even_with_bypass() {
|
||||
let (address, worker) = server(false);
|
||||
let error = reqwest::Client::builder()
|
||||
.no_proxy()
|
||||
.danger_accept_invalid_certs(true)
|
||||
.build()
|
||||
.unwrap()
|
||||
.get(&address)
|
||||
.send()
|
||||
.await
|
||||
.unwrap_err();
|
||||
worker.join().unwrap();
|
||||
let tls = ServerTlsError::from_request(&url::Url::parse(&address).unwrap(), &error).unwrap();
|
||||
assert_eq!(tls.kind, ServerTlsErrorKind::Other);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn connection_refused_is_not_tls() {
|
||||
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let address = format!("https://{}", listener.local_addr().unwrap());
|
||||
drop(listener);
|
||||
let error = reqwest::Client::builder()
|
||||
.no_proxy()
|
||||
.build()
|
||||
.unwrap()
|
||||
.get(address)
|
||||
.send()
|
||||
.await
|
||||
.unwrap_err();
|
||||
assert_eq!(classify(&error), None);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[test]
|
||||
fn wrapped_macos_io_status_retains_the_client_certificate_requirement() {
|
||||
let error = std::io::Error::other(std::io::Error::other(security_framework::base::Error::from(-9863)));
|
||||
let server = url::Url::parse("https://vpn.example.com/login?token=secret").unwrap();
|
||||
let tls = ServerTlsError::from_request(&server, &error).unwrap();
|
||||
assert_eq!(tls.kind, ServerTlsErrorKind::ClientCertificateRequired);
|
||||
assert_eq!(tls.server, "https://vpn.example.com");
|
||||
assert_eq!(classify(&std::io::Error::other("alert certificate required")), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rendering_recovery_retains_client_certificate_requirement() {
|
||||
use crate::process::rendering_recovery::{RecoveryState, RenderingCrash};
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
let mut recovery = RecoveryState::default();
|
||||
assert!(
|
||||
recovery.recover(
|
||||
&RenderingCrash {
|
||||
status: std::process::ExitStatus::from_raw(71 << 8)
|
||||
}
|
||||
.into()
|
||||
)
|
||||
);
|
||||
let error = recovery.terminal(
|
||||
ServerTlsError {
|
||||
server: "https://vpn.example.com".into(),
|
||||
kind: ServerTlsErrorKind::ClientCertificateRequired,
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
assert_eq!(
|
||||
ServerTlsErrorKind::from_error(&error),
|
||||
Some(ServerTlsErrorKind::ClientCertificateRequired)
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn required_client_certificate_is_not_bypassed_by_ignoring_server_trust() {
|
||||
use crate::{
|
||||
gp_params::GpParams,
|
||||
os_profile::{ClientOs, OsProfile},
|
||||
portal::{PreloginOptions, prelogin},
|
||||
};
|
||||
let params = GpParams::builder(OsProfile::builder(ClientOs::Linux).build())
|
||||
.ignore_tls_errors(true)
|
||||
.build();
|
||||
let credential = crate::credential::PasswordCredential::new("alice", "password").into();
|
||||
let cancellation = tokio_util::sync::CancellationToken::new();
|
||||
for operation in ["prelogin", "config", "gateway"] {
|
||||
let (address, worker) = server_with_client_auth(true, SslVerifyMode::PEER | SslVerifyMode::FAIL_IF_NO_PEER_CERT);
|
||||
let error = match operation {
|
||||
"prelogin" => prelogin(&address, ¶ms, PreloginOptions::default())
|
||||
.await
|
||||
.err()
|
||||
.unwrap(),
|
||||
"config" => crate::portal::retrieve_config(&address, &credential, ¶ms, &cancellation)
|
||||
.await
|
||||
.err()
|
||||
.unwrap(),
|
||||
_ => crate::gateway::GatewayLoginClient::new(&address, params.clone())
|
||||
.unwrap()
|
||||
.login(&credential, None, &cancellation)
|
||||
.await
|
||||
.err()
|
||||
.unwrap(),
|
||||
};
|
||||
worker.join().unwrap();
|
||||
let kind =
|
||||
ServerTlsErrorKind::from_error(&error).unwrap_or_else(|| panic!("{operation}: unclassified: {error:?}"));
|
||||
// Secure Transport's TLS 1.2 handshake can return only a generic peer alert.
|
||||
if cfg!(target_os = "macos") {
|
||||
assert!(matches!(
|
||||
kind,
|
||||
ServerTlsErrorKind::ClientCertificateRequired | ServerTlsErrorKind::Other
|
||||
));
|
||||
} else {
|
||||
assert_eq!(
|
||||
kind,
|
||||
ServerTlsErrorKind::ClientCertificateRequired,
|
||||
"{operation}: {error:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn prelogin_accepts_a_valid_identity_and_an_optional_certificate_request() {
|
||||
use crate::{
|
||||
gp_params::GpParams,
|
||||
os_profile::{ClientOs, OsProfile},
|
||||
portal::{PreloginOptions, prelogin},
|
||||
};
|
||||
for required in [false, true] {
|
||||
let verify = if required {
|
||||
SslVerifyMode::PEER | SslVerifyMode::FAIL_IF_NO_PEER_CERT
|
||||
} else {
|
||||
SslVerifyMode::PEER
|
||||
};
|
||||
let (address, worker) = server_with_client_auth(true, verify);
|
||||
let mut builder = GpParams::builder(OsProfile::builder(ClientOs::Linux).build());
|
||||
builder.ignore_tls_errors(true);
|
||||
if required {
|
||||
builder
|
||||
.certificate(Some(
|
||||
concat!(env!("CARGO_MANIFEST_DIR"), "/tests/files/client-identity/rsa-cert.pem").to_owned(),
|
||||
))
|
||||
.sslkey(Some(
|
||||
concat!(env!("CARGO_MANIFEST_DIR"), "/tests/files/client-identity/rsa-pkcs8.pem").to_owned(),
|
||||
));
|
||||
}
|
||||
let result = prelogin(&address, &builder.build(), PreloginOptions::default()).await;
|
||||
worker.join().unwrap();
|
||||
assert!(matches!(result.unwrap(), crate::portal::Prelogin::Saml(_)));
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn failed_response_reads_preserve_the_transport_cause() {
|
||||
for status in [200, 403] {
|
||||
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let address = format!("http://{}", listener.local_addr().unwrap());
|
||||
let worker = thread::spawn(move || {
|
||||
let (mut stream, _) = listener.accept().unwrap();
|
||||
stream.set_read_timeout(Some(Duration::from_secs(5))).unwrap();
|
||||
let mut request = [0; 8192];
|
||||
stream.read(&mut request).unwrap();
|
||||
write!(
|
||||
stream,
|
||||
"HTTP/1.1 {status} Test\r\nContent-Length: 100\r\nConnection: close\r\n\r\ntruncated"
|
||||
)
|
||||
.unwrap();
|
||||
});
|
||||
let response = reqwest::Client::builder()
|
||||
.no_proxy()
|
||||
.build()
|
||||
.unwrap()
|
||||
.get(address)
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
let error = crate::utils::parse_gp_response(response).await.unwrap_err();
|
||||
assert_eq!(error.status.as_u16(), status);
|
||||
assert!(error.source().unwrap().is::<reqwest::Error>());
|
||||
worker.join().unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
use std::error::Error;
|
||||
|
||||
use super::{ServerTlsErrorKind, classify_macos_status};
|
||||
|
||||
pub(super) fn classify(error: &(dyn Error + 'static)) -> Option<ServerTlsErrorKind> {
|
||||
error
|
||||
.downcast_ref::<security_framework::base::Error>()
|
||||
.map(|error| classify_macos_status(error.code()))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
use std::error::Error;
|
||||
|
||||
use super::ServerTlsErrorKind;
|
||||
|
||||
pub(super) fn classify(error: &(dyn Error + 'static)) -> Option<ServerTlsErrorKind> {
|
||||
let stack = error.downcast_ref::<openssl::error::ErrorStack>().or_else(|| {
|
||||
error
|
||||
.downcast_ref::<openssl::ssl::Error>()
|
||||
.and_then(openssl::ssl::Error::ssl_error)
|
||||
})?;
|
||||
// ERR_LIB_SSL and SSL_R_TLSV13_ALERT_CERTIFICATE_REQUIRED from sslerr.h.
|
||||
stack
|
||||
.errors()
|
||||
.iter()
|
||||
.any(|error| error.library_code() == 20 && error.reason_code() == 1116)
|
||||
.then_some(ServerTlsErrorKind::ClientCertificateRequired)
|
||||
}
|
||||
@@ -254,12 +254,18 @@ async fn receive_gateway_login(
|
||||
.await
|
||||
.map_err(|e| {
|
||||
warn!("Network error: {:?}", e);
|
||||
anyhow::anyhow!(PortalError::NetworkError(e))
|
||||
match crate::error::ServerTlsError::from_request(origin, &e) {
|
||||
Some(tls) => anyhow::anyhow!(tls),
|
||||
None => anyhow::anyhow!(PortalError::NetworkError(e)),
|
||||
}
|
||||
})?;
|
||||
|
||||
let endpoint = res.remote_addr();
|
||||
let url = res.url().clone();
|
||||
let res = parse_gp_response(res).await.map_err(|err| {
|
||||
if let Some(tls) = crate::error::ServerTlsError::from_request(origin, &err) {
|
||||
return anyhow::anyhow!(tls);
|
||||
}
|
||||
warn!("Gateway login response failed: {}", err.reason);
|
||||
anyhow::anyhow!("Gateway login error: {}", err.reason)
|
||||
})?;
|
||||
|
||||
@@ -10,7 +10,7 @@ use xmltree::Element;
|
||||
|
||||
use crate::{
|
||||
credential::{AuthCookieCredential, Credential},
|
||||
error::PortalError,
|
||||
error::{PortalError, ServerTlsError},
|
||||
gateway::{Gateway, parse_gateways},
|
||||
gp_params::GpParams,
|
||||
params,
|
||||
@@ -149,6 +149,7 @@ pub async fn retrieve_config(
|
||||
cancellation: &CancellationToken,
|
||||
) -> anyhow::Result<PortalConfig> {
|
||||
let portal = normalize_server(portal)?;
|
||||
let server_url = url::Url::parse(&portal)?;
|
||||
let server = remove_url_scheme(&portal);
|
||||
|
||||
let url = format!("{}/global-protect/getconfig.esp", portal);
|
||||
@@ -170,10 +171,16 @@ pub async fn retrieve_config(
|
||||
result = async {
|
||||
let res = client.post(&url).form(&request_params.body).send().await.map_err(|e| {
|
||||
warn!("Network error: {:?}", e);
|
||||
anyhow::anyhow!(PortalError::NetworkError(e))
|
||||
match ServerTlsError::from_request(&server_url, &e) {
|
||||
Some(tls) => anyhow::anyhow!(tls),
|
||||
None => anyhow::anyhow!(PortalError::NetworkError(e)),
|
||||
}
|
||||
})?;
|
||||
|
||||
parse_gp_response(res).await.or_else(|err| {
|
||||
if let Some(tls) = ServerTlsError::from_request(&server_url, &err) {
|
||||
return Err(anyhow::anyhow!(tls));
|
||||
}
|
||||
if err.status == StatusCode::NOT_FOUND {
|
||||
bail!(PortalError::ConfigError("Config endpoint not found".to_string()));
|
||||
}
|
||||
@@ -227,16 +234,23 @@ async fn retrieve_csc_config(
|
||||
let swg_nonce = csc::swg_nonce();
|
||||
let params = csc::csc_params(&csc_req, username, gp_params, &swg_nonce);
|
||||
let url = format!("{}/global-protect/getconfig_csc.esp", portal);
|
||||
let server_url = url::Url::parse(portal)?;
|
||||
|
||||
info!("Portal CSC config request summary: {}", csc_req.summary());
|
||||
info!("Portal CSC config request params: {}", redact_params(¶ms));
|
||||
|
||||
let res = client.post(&url).form(¶ms).send().await.map_err(|e| {
|
||||
warn!("Network error: {:?}", e);
|
||||
anyhow::anyhow!(PortalError::NetworkError(e))
|
||||
match ServerTlsError::from_request(&server_url, &e) {
|
||||
Some(tls) => anyhow::anyhow!(tls),
|
||||
None => anyhow::anyhow!(PortalError::NetworkError(e)),
|
||||
}
|
||||
})?;
|
||||
|
||||
parse_gp_response(res).await.or_else(|err| {
|
||||
if let Some(tls) = ServerTlsError::from_request(&server_url, &err) {
|
||||
return Err(anyhow::anyhow!(tls));
|
||||
}
|
||||
if err.status == StatusCode::NOT_FOUND {
|
||||
bail!(PortalError::ConfigError("CSC config endpoint not found".to_string()));
|
||||
}
|
||||
|
||||
@@ -135,6 +135,7 @@ pub async fn prelogin(portal: &str, gp_params: &GpParams, options: PreloginOptio
|
||||
);
|
||||
|
||||
let client = Client::try_from(gp_params)?;
|
||||
let server_url = url::Url::parse(&portal)?;
|
||||
|
||||
let mut request = client.post(&prelogin_url);
|
||||
if !request_params.query.is_empty() {
|
||||
@@ -146,10 +147,16 @@ pub async fn prelogin(portal: &str, gp_params: &GpParams, options: PreloginOptio
|
||||
|
||||
let res = request.send().await.map_err(|e| {
|
||||
warn!("Network error: {:?}", e);
|
||||
anyhow::anyhow!(PortalError::NetworkError(e))
|
||||
match crate::error::ServerTlsError::from_request(&server_url, &e) {
|
||||
Some(error) => anyhow!(error),
|
||||
None => anyhow!(PortalError::NetworkError(e)),
|
||||
}
|
||||
})?;
|
||||
|
||||
let res_xml = parse_gp_response(res).await.or_else(|err| {
|
||||
if let Some(tls) = crate::error::ServerTlsError::from_request(&server_url, &err) {
|
||||
return Err(anyhow!(tls));
|
||||
}
|
||||
if err.status == StatusCode::NOT_FOUND {
|
||||
bail!(PortalError::PreloginError("Prelogin endpoint not found".to_string()))
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ pub struct SamlAuthLauncher<'a> {
|
||||
certificate: Option<&'a str>,
|
||||
sslkey: Option<&'a str>,
|
||||
key_password: Option<&'a str>,
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fix_openssl: bool,
|
||||
ignore_tls_errors: bool,
|
||||
#[cfg(feature = "webview-auth")]
|
||||
@@ -66,6 +67,7 @@ impl<'a> SamlAuthLauncher<'a> {
|
||||
certificate: None,
|
||||
sslkey: None,
|
||||
key_password: None,
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fix_openssl: false,
|
||||
ignore_tls_errors: false,
|
||||
#[cfg(feature = "webview-auth")]
|
||||
@@ -113,6 +115,7 @@ impl<'a> SamlAuthLauncher<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub fn fix_openssl(mut self, fix_openssl: bool) -> Self {
|
||||
self.fix_openssl = fix_openssl;
|
||||
self
|
||||
@@ -226,6 +229,7 @@ impl<'a> SamlAuthLauncher<'a> {
|
||||
auth_cmd.arg("--client-version").arg(client_version);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
if self.fix_openssl {
|
||||
auth_cmd.arg("--fix-openssl");
|
||||
}
|
||||
@@ -343,10 +347,12 @@ impl<'a> SamlAuthLauncher<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// `gpauth --browser remote` reads the pasted `globalprotectcallback:` data from the user's terminal.
|
||||
/// `gpauth --browser manual` reads the pasted `globalprotectcallback:` data from the user's terminal.
|
||||
fn auth_stdin(browser: Option<&str>) -> ChildInput<'static> {
|
||||
match browser {
|
||||
Some(browser) if browser.eq_ignore_ascii_case("remote") => ChildInput::Terminal,
|
||||
Some(browser) if browser.eq_ignore_ascii_case("manual") || browser.eq_ignore_ascii_case("remote") => {
|
||||
ChildInput::Terminal
|
||||
}
|
||||
_ => ChildInput::Null,
|
||||
}
|
||||
}
|
||||
@@ -376,6 +382,53 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::os_profile::{ClientOs, OsProfileBuilder};
|
||||
|
||||
#[test]
|
||||
fn server_tls_result_survives_process_decoding_as_a_typed_error() {
|
||||
use crate::error::{ServerTlsError, ServerTlsErrorKind};
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
let output = std::process::Output {
|
||||
status: std::process::ExitStatus::from_raw(0),
|
||||
stdout: br#"{"serverTlsError":{"server":"https://vpn.example.com:8443","kind":"certificate"}}"#.to_vec(),
|
||||
stderr: Vec::new(),
|
||||
};
|
||||
let error = decode_auth_output(output, false).unwrap_err();
|
||||
assert_eq!(
|
||||
error.downcast_ref::<ServerTlsError>(),
|
||||
Some(&ServerTlsError {
|
||||
server: "https://vpn.example.com:8443".into(),
|
||||
kind: ServerTlsErrorKind::Certificate,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn client_certificate_required_result_survives_process_decoding() {
|
||||
use crate::error::{ServerTlsError, ServerTlsErrorKind};
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
let output = std::process::Output {
|
||||
status: std::process::ExitStatus::from_raw(0),
|
||||
stdout: br#"{"serverTlsError":{"server":"https://vpn.example.com","kind":"clientCertificateRequired"}}"#.to_vec(),
|
||||
stderr: Vec::new(),
|
||||
};
|
||||
let error = decode_auth_output(output, false).unwrap_err();
|
||||
let tls = error.downcast_ref::<ServerTlsError>().unwrap();
|
||||
assert_eq!(tls.kind, ServerTlsErrorKind::ClientCertificateRequired);
|
||||
assert_eq!(tls.server, "https://vpn.example.com");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn launches_with_platform_tls_options() {
|
||||
let launcher = SamlAuthLauncher::new("vpn.example.com").ignore_tls_errors(true);
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let launcher = launcher.fix_openssl(true);
|
||||
let args = child_args(launcher);
|
||||
assert_eq!(
|
||||
args.iter().any(|arg| arg == "--fix-openssl"),
|
||||
!cfg!(target_os = "macos")
|
||||
);
|
||||
assert!(args.iter().any(|arg| arg == "--ignore-tls-errors"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn os_profile_sets_os_from_profile() {
|
||||
let profile = OsProfileBuilder::new(ClientOs::Linux).client_version("6.0.0").build();
|
||||
@@ -463,7 +516,9 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_a_remote_browser_reads_the_terminal() {
|
||||
fn only_a_manual_browser_reads_the_terminal() {
|
||||
assert!(matches!(auth_stdin(Some("manual")), ChildInput::Terminal));
|
||||
assert!(matches!(auth_stdin(Some("MANUAL")), ChildInput::Terminal));
|
||||
assert!(matches!(auth_stdin(Some("remote")), ChildInput::Terminal));
|
||||
assert!(matches!(auth_stdin(Some("REMOTE")), ChildInput::Terminal));
|
||||
assert!(matches!(auth_stdin(Some("firefox")), ChildInput::Null));
|
||||
|
||||
@@ -5,6 +5,7 @@ use crate::service::{vpn_env::VpnEnv, vpn_state::VpnState};
|
||||
/// Events that can be emitted by the service
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub enum WsEvent {
|
||||
TunnelState(Option<crate::session::tunnel::TunnelState>),
|
||||
VpnEnv(VpnEnv),
|
||||
VpnState(VpnState),
|
||||
ActiveGui,
|
||||
|
||||
@@ -380,6 +380,7 @@ pub struct UpdateLogLevelRequest(pub String);
|
||||
/// Requests that can be sent to the service
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub enum WsRequest {
|
||||
SetTunnelStatisticsEnabled { enabled: bool },
|
||||
Connect(Box<ConnectRequest>),
|
||||
Disconnect(DisconnectRequest),
|
||||
StopNonTunnelAttachment { connection_id: uuid::Uuid },
|
||||
|
||||
@@ -17,6 +17,9 @@ pub enum ClientMessage {
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(tag = "type", content = "data", rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub enum ServerMessage {
|
||||
TunnelStatistics {
|
||||
snapshot: crate::session::tunnel::TunnelStatisticsSnapshot,
|
||||
},
|
||||
Attached {
|
||||
connection_id: Uuid,
|
||||
current_revision: u64,
|
||||
@@ -39,6 +42,7 @@ pub enum ServerMessage {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(tag = "type", content = "data", rename_all = "camelCase", deny_unknown_fields)]
|
||||
pub enum ServiceResult {
|
||||
TunnelStatisticsSnapshot(crate::session::tunnel::TunnelStatisticsSnapshot),
|
||||
Accepted,
|
||||
StoredHipReport {
|
||||
report_id: String,
|
||||
@@ -192,4 +196,73 @@ mod tests {
|
||||
let encoded = encode(&message).unwrap();
|
||||
assert!(encoded.len() <= MAX_PLAINTEXT);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn full_configuration_and_large_metadata_fit_complete_snapshot_envelopes_at_the_budget() {
|
||||
use crate::{
|
||||
os_profile::HostIdentity,
|
||||
service::{
|
||||
vpn_env::HostInfo,
|
||||
vpn_state::{ConnectedInfo, VpnState},
|
||||
},
|
||||
session::tunnel::{MAX_CONFIGURATION_BYTES, TunnelConfiguration, TunnelPhase, TunnelState, TunnelTransport},
|
||||
};
|
||||
let mut configuration = TunnelConfiguration::default();
|
||||
configuration.included_routes.items = vec!["r".repeat(1024); 15];
|
||||
configuration.included_routes.items.push(String::new());
|
||||
configuration.included_routes.total_count = 16;
|
||||
let padding = MAX_CONFIGURATION_BYTES - serde_json::to_vec(&configuration).unwrap().len();
|
||||
assert!(padding <= 1024);
|
||||
*configuration.included_routes.items.last_mut().unwrap() = "r".repeat(padding);
|
||||
assert_eq!(
|
||||
serde_json::to_vec(&configuration).unwrap().len(),
|
||||
MAX_CONFIGURATION_BYTES
|
||||
);
|
||||
let gateway = Gateway::new("Gateway".repeat(20), "vpn.example.com".into());
|
||||
let info = ConnectInfo::new("portal.example.com".into(), gateway.clone(), vec![gateway; 32]);
|
||||
let snapshot = VpnEnv {
|
||||
tunnel_state: Some(TunnelState {
|
||||
tunnel_id: Uuid::new_v4(),
|
||||
sequence: u64::MAX,
|
||||
phase: TunnelPhase::Connected,
|
||||
configuration_revision: u64::MAX,
|
||||
configuration: Some(configuration),
|
||||
transport: TunnelTransport::IpsecEsp,
|
||||
elapsed_ms: u64::MAX,
|
||||
}),
|
||||
vpn_state: VpnState::Connected(Box::new(ConnectedInfo::new(info, None))),
|
||||
vpnc_script: Some("s".repeat(1024)),
|
||||
auth_executable: "a".repeat(1024),
|
||||
host_info: HostInfo {
|
||||
host_identity: HostIdentity::collect(),
|
||||
},
|
||||
};
|
||||
for mut message in [
|
||||
ServerMessage::Attached {
|
||||
connection_id: Uuid::new_v4(),
|
||||
current_revision: u64::MAX,
|
||||
snapshot: snapshot.clone(),
|
||||
},
|
||||
ServerMessage::Snapshot {
|
||||
current_revision: u64::MAX,
|
||||
snapshot,
|
||||
},
|
||||
] {
|
||||
let remaining = MAX_PLAINTEXT - encode(&message).unwrap().len();
|
||||
let snapshot = match &mut message {
|
||||
ServerMessage::Attached { snapshot, .. } | ServerMessage::Snapshot { snapshot, .. } => snapshot,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
// Existing host/connection metadata has no declared maximum. Fill the
|
||||
// remaining envelope budget, then assert its actual boundary explicitly.
|
||||
snapshot.auth_executable.push_str(&"a".repeat(remaining));
|
||||
assert_eq!(encode(&message).unwrap().len(), MAX_PLAINTEXT);
|
||||
let snapshot = match &mut message {
|
||||
ServerMessage::Attached { snapshot, .. } | ServerMessage::Snapshot { snapshot, .. } => snapshot,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
snapshot.auth_executable.push('a');
|
||||
assert!(matches!(encode(&message), Err(TransportError::MessageTooLarge)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ pub struct HostInfo {
|
||||
/// to the client so that it can configure itself accordingly.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct VpnEnv {
|
||||
pub tunnel_state: Option<crate::session::tunnel::TunnelState>,
|
||||
/// The VPN connection state
|
||||
pub vpn_state: VpnState,
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ mod gateway_sessions;
|
||||
pub mod network;
|
||||
pub mod non_tunnel;
|
||||
pub mod transport;
|
||||
pub mod tunnel;
|
||||
pub use connection::*;
|
||||
pub use gateway_sessions::{ClientAddresses, GatewaySession, GatewaySessions};
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ impl PhysicalNetwork {
|
||||
}
|
||||
|
||||
fn fingerprint(&self) -> anyhow::Result<String> {
|
||||
Ok(sha256::digest(serde_json::to_vec(&self.snapshot)?))
|
||||
Ok(crate::utils::checksum::sha256_hex(serde_json::to_vec(&self.snapshot)?))
|
||||
}
|
||||
|
||||
pub fn capture(control: &dyn CollectionControl) -> anyhow::Result<Self> {
|
||||
|
||||
@@ -320,8 +320,8 @@ fn parse_hip_check(root: &Element) -> Result<HipCheck, GatewayRequestError> {
|
||||
.map_err(|_| GatewayRequestError::MalformedResponse)?,
|
||||
None => 0,
|
||||
};
|
||||
// Limit this client's supported response delay to one hour. The official
|
||||
// registry scheduling cap is not evidence of a wire-protocol maximum.
|
||||
// Accept response delays up to one hour as a client policy, not a
|
||||
// wire-protocol maximum.
|
||||
if delay > 3600 {
|
||||
return Err(GatewayRequestError::MalformedResponse);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,353 @@
|
||||
//! Observed tunnel data, shared by standalone clients and service consumers.
|
||||
//! These values describe negotiated settings, not verified operating-system state.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub const MAX_CONFIGURATION_BYTES: usize = 16 * 1024;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum TunnelPhase {
|
||||
Establishing,
|
||||
Connected,
|
||||
Reconnecting,
|
||||
Ended,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum TunnelTransport {
|
||||
Negotiating,
|
||||
IpsecEsp,
|
||||
SslTls,
|
||||
Unavailable,
|
||||
}
|
||||
|
||||
impl TunnelTransport {
|
||||
pub fn is_active(self) -> bool {
|
||||
matches!(self, Self::IpsecEsp | Self::SslTls)
|
||||
}
|
||||
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::Negotiating => "Negotiating",
|
||||
Self::IpsecEsp => "IPsec (ESP)",
|
||||
Self::SslTls => "SSL/TLS",
|
||||
Self::Unavailable => "Unavailable",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TunnelList {
|
||||
pub items: Vec<String>,
|
||||
pub total_count: u32,
|
||||
pub truncated: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TunnelAddress {
|
||||
pub address: String,
|
||||
pub netmask: Option<String>,
|
||||
pub prefix_length: Option<u8>,
|
||||
}
|
||||
|
||||
impl TunnelAddress {
|
||||
pub fn display(&self) -> String {
|
||||
match self.prefix_length {
|
||||
Some(prefix) => format!("{}/{prefix}", self.address),
|
||||
None => match &self.netmask {
|
||||
Some(netmask) => format!("{} (mask {netmask})", self.address),
|
||||
None => self.address.clone(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TunnelConfiguration {
|
||||
pub interface: Option<String>,
|
||||
pub ipv4: Option<TunnelAddress>,
|
||||
pub ipv6: Option<TunnelAddress>,
|
||||
pub server_ip: Option<String>,
|
||||
pub dns: TunnelList,
|
||||
pub search_domains: TunnelList,
|
||||
pub split_dns: TunnelList,
|
||||
pub included_routes: TunnelList,
|
||||
pub excluded_routes: TunnelList,
|
||||
pub mtu: Option<u32>,
|
||||
pub truncated: bool,
|
||||
}
|
||||
|
||||
impl TunnelConfiguration {
|
||||
/// Bound observation payloads without modifying native network configuration.
|
||||
/// Whole list entries are omitted before shortening scalar text. Counts and
|
||||
/// truncation flags preserve the distinction between absent and omitted data.
|
||||
/// Returns false if even the fixed JSON shape cannot fit the supplied budget.
|
||||
pub fn limit_encoded_size(&mut self, limit: usize) -> bool {
|
||||
while serde_json::to_vec(self).expect("configuration is serializable").len() > limit {
|
||||
self.truncated = true;
|
||||
let lists = [
|
||||
&mut self.excluded_routes,
|
||||
&mut self.included_routes,
|
||||
&mut self.split_dns,
|
||||
&mut self.search_domains,
|
||||
&mut self.dns,
|
||||
];
|
||||
if let Some(list) = lists.into_iter().find(|list| !list.items.is_empty()) {
|
||||
list.items.pop();
|
||||
list.truncated = true;
|
||||
continue;
|
||||
}
|
||||
let mut scalars = vec![&mut self.interface, &mut self.server_ip];
|
||||
if let Some(address) = &mut self.ipv4 {
|
||||
scalars.push(&mut address.netmask);
|
||||
if address.address.len() > 128 {
|
||||
address.address.truncate(address.address.floor_char_boundary(128));
|
||||
address.prefix_length = None;
|
||||
}
|
||||
}
|
||||
if let Some(address) = &mut self.ipv6 {
|
||||
scalars.push(&mut address.netmask);
|
||||
if address.address.len() > 128 {
|
||||
address.address.truncate(address.address.floor_char_boundary(128));
|
||||
address.prefix_length = None;
|
||||
}
|
||||
}
|
||||
match scalars
|
||||
.into_iter()
|
||||
.max_by_key(|value| value.as_ref().map_or(0, String::len))
|
||||
{
|
||||
Some(Some(text)) if !text.is_empty() => {
|
||||
text.truncate(text.floor_char_boundary(text.len() / 2));
|
||||
}
|
||||
_ => return serde_json::to_vec(self).expect("configuration is serializable").len() <= limit,
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TunnelState {
|
||||
pub tunnel_id: Uuid,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub sequence: u64,
|
||||
pub phase: TunnelPhase,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub configuration_revision: u64,
|
||||
pub configuration: Option<TunnelConfiguration>,
|
||||
pub transport: TunnelTransport,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub elapsed_ms: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TunnelStatistics {
|
||||
pub tunnel_id: Uuid,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub sequence: u64,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub state_sequence: u64,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub configuration_revision: u64,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub elapsed_ms: u64,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub received_bytes: u64,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub sent_bytes: u64,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub received_packets: u64,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub sent_packets: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum TunnelStatisticsState {
|
||||
Disabled,
|
||||
Waiting,
|
||||
Fresh,
|
||||
Stale,
|
||||
Ended,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TunnelStatisticsView {
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub sequence: u64,
|
||||
pub tunnel_id: Uuid,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub state_sequence: u64,
|
||||
pub phase: TunnelPhase,
|
||||
pub transport: TunnelTransport,
|
||||
pub state: TunnelStatisticsState,
|
||||
#[serde(with = "decimal")]
|
||||
#[specta(type = String)]
|
||||
pub elapsed_ms: u64,
|
||||
#[serde(with = "optional_decimal")]
|
||||
#[specta(type = Option<String>)]
|
||||
pub sample_age_ms: Option<u64>,
|
||||
pub sample: Option<TunnelStatistics>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum TunnelUnavailableReason {
|
||||
NoTunnel,
|
||||
NonTunnel,
|
||||
ObservationFailed,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(tag = "kind", rename_all = "camelCase")]
|
||||
pub enum TunnelStatisticsSnapshot {
|
||||
Available(TunnelStatisticsView),
|
||||
Unavailable { reason: TunnelUnavailableReason },
|
||||
}
|
||||
|
||||
impl TunnelStatisticsSnapshot {
|
||||
pub fn unavailable(reason: TunnelUnavailableReason) -> Self {
|
||||
Self::Unavailable { reason }
|
||||
}
|
||||
|
||||
pub fn view(&self) -> Option<&TunnelStatisticsView> {
|
||||
match self {
|
||||
Self::Available(view) => Some(view),
|
||||
Self::Unavailable { .. } => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tunnel_id(&self) -> Option<Uuid> {
|
||||
self.view().map(|view| view.tunnel_id)
|
||||
}
|
||||
|
||||
pub fn sequence(&self) -> Option<u64> {
|
||||
self.view().map(|view| view.sequence)
|
||||
}
|
||||
|
||||
pub fn state_sequence(&self) -> Option<u64> {
|
||||
self.view().map(|view| view.state_sequence)
|
||||
}
|
||||
|
||||
pub fn disabled(&self) -> Self {
|
||||
let mut snapshot = self.clone();
|
||||
if let Self::Available(view) = &mut snapshot {
|
||||
if view.state != TunnelStatisticsState::Ended {
|
||||
view.state = TunnelStatisticsState::Disabled;
|
||||
}
|
||||
}
|
||||
snapshot
|
||||
}
|
||||
|
||||
pub fn stale(&self) -> Self {
|
||||
let mut snapshot = self.clone();
|
||||
if let Self::Available(view) = &mut snapshot {
|
||||
if matches!(
|
||||
view.state,
|
||||
TunnelStatisticsState::Fresh | TunnelStatisticsState::Waiting
|
||||
) {
|
||||
view.state = TunnelStatisticsState::Stale;
|
||||
}
|
||||
}
|
||||
snapshot
|
||||
}
|
||||
}
|
||||
|
||||
mod decimal {
|
||||
use serde::{Deserialize, Deserializer, Serializer};
|
||||
|
||||
pub fn serialize<S: Serializer>(value: &u64, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
serializer.collect_str(value)
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<u64, D::Error> {
|
||||
let value = String::deserialize(deserializer)?;
|
||||
if value.is_empty() || !value.bytes().all(|byte| byte.is_ascii_digit()) {
|
||||
return Err(serde::de::Error::custom("expected an unsigned decimal string"));
|
||||
}
|
||||
value.parse().map_err(serde::de::Error::custom)
|
||||
}
|
||||
}
|
||||
|
||||
mod optional_decimal {
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
pub fn serialize<S: Serializer>(value: &Option<u64>, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
value.map(|value| value.to_string()).serialize(serializer)
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result<Option<u64>, D::Error> {
|
||||
Option::<String>::deserialize(deserializer)?
|
||||
.map(|value| {
|
||||
if value.is_empty() || !value.bytes().all(|byte| byte.is_ascii_digit()) {
|
||||
return Err(serde::de::Error::custom("expected an unsigned decimal string"));
|
||||
}
|
||||
value.parse().map_err(serde::de::Error::custom)
|
||||
})
|
||||
.transpose()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn counters_above_javascript_precision_round_trip_as_decimal_strings() {
|
||||
let sample = TunnelStatistics {
|
||||
tunnel_id: Uuid::nil(),
|
||||
sequence: 1,
|
||||
state_sequence: 1,
|
||||
configuration_revision: 1,
|
||||
elapsed_ms: 1000,
|
||||
received_bytes: (1_u64 << 53) + 1,
|
||||
sent_bytes: u64::MAX,
|
||||
received_packets: 3,
|
||||
sent_packets: 4,
|
||||
};
|
||||
let value = serde_json::to_value(&sample).unwrap();
|
||||
assert_eq!(value["receivedBytes"], "9007199254740993");
|
||||
assert_eq!(value["sentBytes"], "18446744073709551615");
|
||||
assert_eq!(
|
||||
serde_json::from_value::<TunnelStatistics>(value.clone()).unwrap(),
|
||||
sample
|
||||
);
|
||||
let mut numeric = value;
|
||||
numeric["receivedBytes"] = serde_json::json!(9007199254740993_u64);
|
||||
assert!(serde_json::from_value::<TunnelStatistics>(numeric).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unavailable_has_no_synthetic_counters() {
|
||||
let snapshot = TunnelStatisticsSnapshot::unavailable(TunnelUnavailableReason::NonTunnel);
|
||||
let value = serde_json::to_value(&snapshot).unwrap();
|
||||
assert_eq!(value, serde_json::json!({"kind": "unavailable", "reason": "nonTunnel"}));
|
||||
assert_eq!(
|
||||
serde_json::from_value::<TunnelStatisticsSnapshot>(value).unwrap(),
|
||||
snapshot
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,43 @@
|
||||
use std::path::Path;
|
||||
use std::{
|
||||
fmt::Write as _,
|
||||
fs::File,
|
||||
io::{self, Read},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use anyhow::bail;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
pub fn sha256_hex(data: impl AsRef<[u8]>) -> String {
|
||||
digest_hex(&Sha256::digest(data.as_ref()))
|
||||
}
|
||||
|
||||
pub fn file_sha256(path: impl AsRef<Path>) -> io::Result<String> {
|
||||
let mut file = File::open(path)?;
|
||||
let mut hasher = Sha256::new();
|
||||
let mut buffer = [0; 8192];
|
||||
loop {
|
||||
let count = match file.read(&mut buffer) {
|
||||
Ok(0) => break,
|
||||
Ok(count) => count,
|
||||
Err(error) if error.kind() == io::ErrorKind::Interrupted => continue,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
hasher.update(&buffer[..count]);
|
||||
}
|
||||
Ok(digest_hex(&hasher.finalize()))
|
||||
}
|
||||
|
||||
fn digest_hex(digest: &[u8]) -> String {
|
||||
let mut hex = String::with_capacity(digest.len() * 2);
|
||||
for byte in digest {
|
||||
write!(&mut hex, "{byte:02x}").expect("writing to a String cannot fail");
|
||||
}
|
||||
hex
|
||||
}
|
||||
|
||||
pub fn verify_checksum(path: &str, expected: &str) -> anyhow::Result<()> {
|
||||
let file = Path::new(&path);
|
||||
let checksum = sha256::try_digest(&file)?;
|
||||
let checksum = file_sha256(path)?;
|
||||
|
||||
if checksum != expected {
|
||||
bail!("Checksum mismatch, expected: {}, actual: {}", expected, checksum);
|
||||
@@ -12,3 +45,43 @@ pub fn verify_checksum(path: &str, expected: &str) -> anyhow::Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::io::Write;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn known_sha256_vectors_use_lowercase_hex() {
|
||||
assert_eq!(
|
||||
sha256_hex(b""),
|
||||
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
);
|
||||
assert_eq!(
|
||||
sha256_hex(b"abc"),
|
||||
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hashes_files_across_buffer_boundaries_and_checks_expected_digest() {
|
||||
let mut file = tempfile::NamedTempFile::new().unwrap();
|
||||
file.write_all(&vec![b'a'; 1_000_000]).unwrap();
|
||||
let expected = "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0";
|
||||
|
||||
assert_eq!(file_sha256(file.path()).unwrap(), expected);
|
||||
verify_checksum(file.path().to_str().unwrap(), expected).unwrap();
|
||||
assert!(verify_checksum(file.path().to_str().unwrap(), "wrong").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hashes_empty_files_and_propagates_file_errors() {
|
||||
let file = tempfile::NamedTempFile::new().unwrap();
|
||||
assert_eq!(file_sha256(file.path()).unwrap(), sha256_hex(b""));
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let error = file_sha256(directory.path().join("missing")).unwrap_err();
|
||||
assert_eq!(error.kind(), std::io::ErrorKind::NotFound);
|
||||
assert!(file_sha256(directory.path()).is_err());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
//! PEM/DER normalization; usable key and certificate imports stay with native TLS.
|
||||
use pkcs8::{
|
||||
AlgorithmIdentifierRef, EncryptedPrivateKeyInfoRef, ObjectIdentifier, PrivateKeyInfoRef, SecretDocument,
|
||||
der::{
|
||||
Decode, Reader, SliceReader, Tag, Tagged,
|
||||
asn1::{AnyRef, OctetStringRef, SequenceRef},
|
||||
},
|
||||
};
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
use super::{request::RequestIdentityError, traditional_key};
|
||||
|
||||
pub(super) enum TraditionalKeyFormat {
|
||||
Sec1Der,
|
||||
PlainPem,
|
||||
EncryptedPem,
|
||||
}
|
||||
|
||||
struct PemBlock {
|
||||
tag: String,
|
||||
headers: pem::HeaderMap,
|
||||
contents: Zeroizing<Vec<u8>>,
|
||||
}
|
||||
|
||||
impl PemBlock {
|
||||
fn encoded(&self) -> Zeroizing<Vec<u8>> {
|
||||
let mut block = pem::Pem::new(&self.tag, self.contents.as_slice());
|
||||
*block.headers_mut() = self.headers.clone();
|
||||
let encoded = Zeroizing::new(pem::encode(&block).into_bytes());
|
||||
// The PEM crate owns a copy of the decoded private key as well.
|
||||
drop(Zeroizing::new(block.into_contents()));
|
||||
encoded
|
||||
}
|
||||
}
|
||||
|
||||
fn is_pem(bytes: &[u8]) -> bool {
|
||||
bytes.windows(b"-----BEGIN".len()).any(|part| part == b"-----BEGIN")
|
||||
}
|
||||
|
||||
// Adopt decoded blocks immediately, including ignored keys in combined files.
|
||||
fn blocks(bytes: &[u8]) -> Result<Vec<PemBlock>, pem::PemError> {
|
||||
Ok(
|
||||
pem::parse_many(bytes)?
|
||||
.into_iter()
|
||||
.map(|block| PemBlock {
|
||||
tag: block.tag().to_owned(),
|
||||
headers: block.headers().clone(),
|
||||
contents: Zeroizing::new(block.into_contents()),
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn private_key(bytes: &[u8], passphrase: Option<&str>) -> anyhow::Result<Zeroizing<Vec<u8>>> {
|
||||
let pem_input = is_pem(bytes);
|
||||
let block = if pem_input {
|
||||
blocks(bytes)
|
||||
.map_err(|_| RequestIdentityError::InvalidKey)?
|
||||
.into_iter()
|
||||
.find(|block| block.tag.ends_with("PRIVATE KEY"))
|
||||
.ok_or(RequestIdentityError::NoKey)?
|
||||
} else {
|
||||
// Unlike combined PEM, a standalone DER certificate cannot include a key.
|
||||
if x509_cert::Certificate::from_der(bytes).is_ok() {
|
||||
return Err(RequestIdentityError::NoKey.into());
|
||||
}
|
||||
PemBlock {
|
||||
tag: der_key_tag(bytes)
|
||||
.map_err(|_| RequestIdentityError::InvalidKey)?
|
||||
.to_owned(),
|
||||
headers: pem::HeaderMap::default(),
|
||||
contents: Zeroizing::new(bytes.to_vec()),
|
||||
}
|
||||
};
|
||||
let der = &block.contents;
|
||||
let document = if traditional_encryption(&block)? {
|
||||
if !matches!(block.tag.as_str(), "RSA PRIVATE KEY" | "EC PRIVATE KEY") {
|
||||
return Err(RequestIdentityError::InvalidKey.into());
|
||||
}
|
||||
traditional_key::normalize(&block.encoded(), TraditionalKeyFormat::EncryptedPem, passphrase)?
|
||||
} else {
|
||||
match block.tag.as_str() {
|
||||
"PRIVATE KEY" => SecretDocument::try_from(der.as_slice()).map_err(|_| RequestIdentityError::InvalidKey)?,
|
||||
"RSA PRIVATE KEY" => {
|
||||
// PKCS#8 stores the original PKCS#1 bytes inside an RSA algorithm envelope.
|
||||
// Native TLS validates the RSA key, as it does for existing PKCS#8 input.
|
||||
let algorithm = AlgorithmIdentifierRef {
|
||||
oid: ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.1"),
|
||||
parameters: Some(AnyRef::NULL),
|
||||
};
|
||||
let private_key = OctetStringRef::new(der).map_err(|_| RequestIdentityError::InvalidKey)?;
|
||||
let info = PrivateKeyInfoRef::new(algorithm, private_key);
|
||||
SecretDocument::encode_msg(&info).map_err(|_| RequestIdentityError::InvalidKey)?
|
||||
}
|
||||
"ENCRYPTED PRIVATE KEY" => decrypt(der, passphrase)?,
|
||||
"EC PRIVATE KEY" => {
|
||||
if pem_input {
|
||||
traditional_key::normalize(&block.encoded(), TraditionalKeyFormat::PlainPem, passphrase)?
|
||||
} else {
|
||||
traditional_key::normalize(der, TraditionalKeyFormat::Sec1Der, passphrase)?
|
||||
}
|
||||
}
|
||||
_ => return Err(RequestIdentityError::UnsupportedKeyFormat.into()),
|
||||
}
|
||||
};
|
||||
PrivateKeyInfoRef::from_der(document.as_bytes()).map_err(|_| RequestIdentityError::InvalidKey)?;
|
||||
let pem = document.to_pem("PRIVATE KEY", pkcs8::LineEnding::LF)?;
|
||||
Ok(Zeroizing::new(pem.as_bytes().to_vec()))
|
||||
}
|
||||
|
||||
// Only choose a container here. The selected decoder/native importer validates
|
||||
// the key. Decoding the complete outer sequence rejects concatenated DER input.
|
||||
fn der_key_tag(bytes: &[u8]) -> Result<&'static str, pkcs8::der::Error> {
|
||||
let sequence = <&SequenceRef>::from_der(bytes)?;
|
||||
let mut reader = SliceReader::new(sequence.as_bytes())?;
|
||||
let first: AnyRef = reader.decode()?;
|
||||
Ok(match (first.tag(), Tag::peek(&reader)?) {
|
||||
(Tag::Integer, Tag::Sequence) => "PRIVATE KEY",
|
||||
(Tag::Integer, Tag::Integer) => "RSA PRIVATE KEY",
|
||||
(Tag::Integer, Tag::OctetString) => "EC PRIVATE KEY",
|
||||
(Tag::Sequence, Tag::OctetString) => "ENCRYPTED PRIVATE KEY",
|
||||
_ => return Err(pkcs8::der::ErrorKind::Failed.into()),
|
||||
})
|
||||
}
|
||||
|
||||
fn traditional_encryption(block: &PemBlock) -> Result<bool, RequestIdentityError> {
|
||||
let mut proc_type = None;
|
||||
let mut dek_info = None;
|
||||
for (name, value) in block.headers.iter() {
|
||||
let slot = match name {
|
||||
"Proc-Type" => &mut proc_type,
|
||||
"DEK-Info" => &mut dek_info,
|
||||
_ => continue,
|
||||
};
|
||||
if slot.replace(value).is_some() {
|
||||
return Err(RequestIdentityError::InvalidKey);
|
||||
}
|
||||
}
|
||||
if proc_type.is_none() && dek_info.is_none() {
|
||||
return Ok(false);
|
||||
}
|
||||
let (Some("4,ENCRYPTED"), Some(dek_info)) = (proc_type, dek_info) else {
|
||||
return Err(RequestIdentityError::InvalidKey);
|
||||
};
|
||||
let (cipher, iv) = dek_info.split_once(',').ok_or(RequestIdentityError::InvalidKey)?;
|
||||
let block_size = match cipher {
|
||||
"AES-128-CBC" | "AES-192-CBC" | "AES-256-CBC" => 16,
|
||||
"DES-EDE3-CBC" => 8,
|
||||
_ => return Err(RequestIdentityError::UnsupportedEncryption),
|
||||
};
|
||||
if iv.len() != block_size * 2
|
||||
|| !iv.bytes().all(|byte| byte.is_ascii_hexdigit())
|
||||
|| block.contents.is_empty()
|
||||
|| block.contents.len() % block_size != 0
|
||||
{
|
||||
return Err(RequestIdentityError::InvalidKey);
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn decrypt(der: &[u8], passphrase: Option<&str>) -> anyhow::Result<SecretDocument> {
|
||||
// pkcs5 collapses unknown outer PBE OIDs into a generic DER value error.
|
||||
// Inspect the typed envelope first so legacy PBE is not called malformed.
|
||||
let algorithm = pkcs8::der::asn1::AnyRef::from_der(der)
|
||||
.and_then(|value| {
|
||||
value.sequence(|reader| {
|
||||
let algorithm = pkcs8::AlgorithmIdentifierRef::decode(reader)?;
|
||||
let _: &pkcs8::der::asn1::OctetStringRef = reader.decode()?;
|
||||
Ok(algorithm.oid)
|
||||
})
|
||||
})
|
||||
.map_err(|_| RequestIdentityError::InvalidKey)?;
|
||||
if algorithm != pkcs8::pkcs5::pbes2::PBES2_OID {
|
||||
// PKCS#12 PBE-SHA1-3DES inside standalone PKCS#8 is not implemented by
|
||||
// RustCrypto. Only this known legacy scheme uses the optional executable.
|
||||
if algorithm == pkcs8::ObjectIdentifier::new_unwrap("1.2.840.113549.1.12.1.3") {
|
||||
return super::legacy_pkcs8::decrypt(der, passphrase);
|
||||
}
|
||||
return Err(RequestIdentityError::UnsupportedEncryption.into());
|
||||
}
|
||||
// Decode the full encryption scheme, including its KDF/PRF/cipher, before
|
||||
// asking for a password. Unsupported algorithms must not cause prompt loops.
|
||||
let encrypted = EncryptedPrivateKeyInfoRef::from_der(der).map_err(|error| match error.kind() {
|
||||
pkcs8::der::ErrorKind::OidUnknown { .. } => RequestIdentityError::UnsupportedEncryption,
|
||||
_ => RequestIdentityError::InvalidKey,
|
||||
})?;
|
||||
let passphrase = passphrase.ok_or(RequestIdentityError::NoPassphrase("PEM"))?;
|
||||
let mut plaintext = Zeroizing::new(encrypted.encrypted_data.as_bytes().to_vec());
|
||||
let decrypted = encrypted
|
||||
.encryption_algorithm
|
||||
.decrypt_in_place(passphrase, &mut plaintext)
|
||||
.map_err(|_| RequestIdentityError::DecryptError("PEM"))?;
|
||||
SecretDocument::try_from(decrypted).map_err(|_| RequestIdentityError::DecryptError("PEM").into())
|
||||
}
|
||||
|
||||
pub(super) fn certificate_chain(bytes: &[u8]) -> anyhow::Result<Zeroizing<Vec<u8>>> {
|
||||
if !is_pem(bytes) {
|
||||
return certificate_pem(bytes).map(|pem| Zeroizing::new(pem.into_bytes()));
|
||||
}
|
||||
let mut chain = Zeroizing::new(Vec::new());
|
||||
for block in blocks(bytes).map_err(|_| RequestIdentityError::InvalidCertificate)? {
|
||||
if block.tag == "CERTIFICATE" {
|
||||
let encoded = certificate_pem(&block.contents)?;
|
||||
chain.extend_from_slice(encoded.as_bytes());
|
||||
}
|
||||
}
|
||||
if chain.is_empty() {
|
||||
return Err(RequestIdentityError::InvalidCertificate.into());
|
||||
}
|
||||
Ok(chain)
|
||||
}
|
||||
|
||||
fn certificate_pem(der: &[u8]) -> anyhow::Result<String> {
|
||||
x509_cert::Certificate::from_der(der).map_err(|_| RequestIdentityError::InvalidCertificate)?;
|
||||
Ok(pem::encode_config(
|
||||
&pem::Pem::new("CERTIFICATE", der),
|
||||
pem::EncodeConfig::new().set_line_ending(pem::LineEnding::LF),
|
||||
))
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
//! Optional compatibility conversion for standalone PKCS#12 PBE-SHA1-3DES keys.
|
||||
//! The executable is a runtime option, not a linked or bundled dependency.
|
||||
use std::{
|
||||
io::{ErrorKind, Read, Write},
|
||||
os::{fd::AsFd, unix::process::CommandExt},
|
||||
process::{Child, Command, Stdio},
|
||||
thread,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use nix::{
|
||||
fcntl::{FcntlArg, OFlag, fcntl},
|
||||
sys::signal::{Signal, killpg},
|
||||
unistd::Pid,
|
||||
};
|
||||
use pkcs8::SecretDocument;
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
use super::request::RequestIdentityError::{self, LegacyKeyConversion};
|
||||
|
||||
const TIMEOUT: Duration = Duration::from_secs(10);
|
||||
const MAX_OUTPUT: u64 = 1024 * 1024;
|
||||
const MAX_PASSWORD_BYTES: usize = 1023;
|
||||
|
||||
// The converter owns a separate process group, including wrapper descendants.
|
||||
// Clean up that group and reap the direct child on every return path.
|
||||
struct Converter(Child);
|
||||
|
||||
impl Drop for Converter {
|
||||
fn drop(&mut self) {
|
||||
let _ = killpg(Pid::from_raw(self.0.id() as i32), Signal::SIGKILL);
|
||||
let _ = self.0.wait();
|
||||
}
|
||||
}
|
||||
|
||||
fn nonblocking(pipe: &impl AsFd) -> anyhow::Result<()> {
|
||||
fcntl(pipe, FcntlArg::F_SETFL(OFlag::O_NONBLOCK))
|
||||
.map_err(|_| LegacyKeyConversion("could not configure converter pipes"))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Read at most one chunk per iteration so a busy pipe cannot starve the deadline.
|
||||
// Returns true only after EOF; inherited pipes remain subject to the deadline.
|
||||
fn read_output(pipe: &mut impl Read, output: &mut Zeroizing<Vec<u8>>, limit: u64) -> anyhow::Result<bool> {
|
||||
let mut buffer = Zeroizing::new([0u8; 8192]);
|
||||
match pipe.read(buffer.as_mut_slice()) {
|
||||
Ok(0) => Ok(true),
|
||||
Ok(count) => {
|
||||
if output.len() as u64 + count as u64 > limit {
|
||||
return Err(LegacyKeyConversion("converter output exceeds the size limit").into());
|
||||
}
|
||||
output.extend_from_slice(&buffer[..count]);
|
||||
Ok(false)
|
||||
}
|
||||
Err(error) if matches!(error.kind(), ErrorKind::WouldBlock | ErrorKind::Interrupted) => Ok(false),
|
||||
Err(_) => Err(LegacyKeyConversion("could not read converter output").into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn decrypt(der: &[u8], passphrase: Option<&str>) -> anyhow::Result<SecretDocument> {
|
||||
let passphrase = passphrase.ok_or(RequestIdentityError::NoPassphrase("PEM"))?;
|
||||
// The command's line reader reserves one byte for a terminator. The linked
|
||||
// OpenSSL API accepted 1024 bytes, but the CLI would truncate that password.
|
||||
if passphrase.len() > MAX_PASSWORD_BYTES {
|
||||
return Err(LegacyKeyConversion("the password exceeds OpenSSL's 1023-byte input limit").into());
|
||||
}
|
||||
// OpenSSL's pipe password source reads one line. Never silently truncate it.
|
||||
if passphrase.contains(['\r', '\n', '\0']) {
|
||||
return Err(LegacyKeyConversion("the password cannot be passed through OpenSSL's line-based input").into());
|
||||
}
|
||||
|
||||
// Only encrypted input touches disk, in a private temporary file. The
|
||||
// original file is never changed and decrypted output stays in memory.
|
||||
let mut input = tempfile::NamedTempFile::new()?;
|
||||
input.write_all(pem::encode(&pem::Pem::new("ENCRYPTED PRIVATE KEY", der)).as_bytes())?;
|
||||
let child = Command::new("openssl")
|
||||
.args([
|
||||
"pkcs8", "-topk8", "-nocrypt", "-inform", "PEM", "-outform", "DER", "-in",
|
||||
])
|
||||
.arg(input.path())
|
||||
.args(["-passin", "stdin"])
|
||||
.env("LC_ALL", "C")
|
||||
.process_group(0)
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.map_err(|_| LegacyKeyConversion("the openssl executable is unavailable"))?;
|
||||
let mut converter = Converter(child);
|
||||
let mut stdin = converter.0.stdin.take();
|
||||
let mut stdout = converter.0.stdout.take().unwrap();
|
||||
let mut stderr = converter.0.stderr.take().unwrap();
|
||||
nonblocking(stdin.as_ref().unwrap())?;
|
||||
nonblocking(&stdout)?;
|
||||
nonblocking(&stderr)?;
|
||||
let mut password = Zeroizing::new(passphrase.as_bytes().to_vec());
|
||||
password.push(b'\n');
|
||||
let mut written = 0;
|
||||
let mut input_failed = false;
|
||||
let mut output = Zeroizing::new(Vec::new());
|
||||
let mut diagnostic = Zeroizing::new(Vec::new());
|
||||
let mut output_done = false;
|
||||
let mut diagnostic_done = false;
|
||||
let mut status = None;
|
||||
let started = Instant::now();
|
||||
let status = loop {
|
||||
if started.elapsed() >= TIMEOUT {
|
||||
return Err(LegacyKeyConversion("conversion timed out").into());
|
||||
}
|
||||
if let Some(pipe) = stdin.as_mut() {
|
||||
match pipe.write(&password[written..]) {
|
||||
Ok(0) => {
|
||||
input_failed = true;
|
||||
stdin = None;
|
||||
}
|
||||
Ok(count) => {
|
||||
written += count;
|
||||
if written == password.len() {
|
||||
stdin = None;
|
||||
}
|
||||
}
|
||||
Err(error) if matches!(error.kind(), ErrorKind::WouldBlock | ErrorKind::Interrupted) => {}
|
||||
Err(_) => {
|
||||
input_failed = true;
|
||||
stdin = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !output_done {
|
||||
output_done = read_output(&mut stdout, &mut output, MAX_OUTPUT)?;
|
||||
}
|
||||
if !diagnostic_done {
|
||||
diagnostic_done = read_output(&mut stderr, &mut diagnostic, 16 * 1024)?;
|
||||
}
|
||||
if status.is_none() {
|
||||
status = converter
|
||||
.0
|
||||
.try_wait()
|
||||
.map_err(|_| LegacyKeyConversion("could not wait for the converter"))?;
|
||||
}
|
||||
if let Some(status) = status {
|
||||
if output_done && diagnostic_done && stdin.is_none() {
|
||||
break status;
|
||||
}
|
||||
}
|
||||
thread::sleep(Duration::from_millis(20));
|
||||
};
|
||||
if status.success() && input_failed {
|
||||
return Err(LegacyKeyConversion("could not send the password").into());
|
||||
}
|
||||
|
||||
if !status.success() {
|
||||
// Never include the command's output in user-facing errors: it can contain
|
||||
// key material. Preserve the old Linux password retry contract only for
|
||||
// an explicit decryption failure, not missing cipher/provider support.
|
||||
if [b"bad decrypt".as_slice(), b"pkcs12 cipherfinal error".as_slice()]
|
||||
.iter()
|
||||
.any(|message| diagnostic.windows(message.len()).any(|window| window == *message))
|
||||
{
|
||||
return Err(RequestIdentityError::DecryptError("PEM").into());
|
||||
}
|
||||
return Err(LegacyKeyConversion("this OpenSSL installation cannot decrypt the key").into());
|
||||
}
|
||||
SecretDocument::try_from(output.as_slice()).map_err(|_| LegacyKeyConversion("invalid converted key").into())
|
||||
}
|
||||
@@ -5,10 +5,25 @@ pub mod checksum;
|
||||
pub mod crypto;
|
||||
pub mod endpoint;
|
||||
pub mod env_utils;
|
||||
mod identity_encoding;
|
||||
mod legacy_pkcs8;
|
||||
pub mod lock_file;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub mod openssl;
|
||||
#[cfg(target_os = "macos")]
|
||||
#[path = "pkcs12_identity/macos.rs"]
|
||||
mod pkcs12_identity;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[path = "pkcs12_identity/openssl.rs"]
|
||||
mod pkcs12_identity;
|
||||
pub mod redact;
|
||||
pub mod request;
|
||||
#[cfg(target_os = "macos")]
|
||||
#[path = "traditional_key/macos.rs"]
|
||||
mod traditional_key;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
#[path = "traditional_key/openssl.rs"]
|
||||
mod traditional_key;
|
||||
#[cfg(feature = "tauri")]
|
||||
pub mod window;
|
||||
|
||||
@@ -51,6 +66,8 @@ pub struct GpError {
|
||||
pub status: StatusCode,
|
||||
pub reason: String,
|
||||
body: String,
|
||||
#[source]
|
||||
source: Option<reqwest::Error>,
|
||||
}
|
||||
|
||||
impl GpError {
|
||||
@@ -63,9 +80,7 @@ pub async fn parse_gp_response(res: Response) -> anyhow::Result<String, GpError>
|
||||
let status = res.status();
|
||||
|
||||
if status.is_client_error() || status.is_server_error() {
|
||||
let (reason, body) = parse_gp_error(res).await;
|
||||
|
||||
return Err(GpError { status, reason, body });
|
||||
return Err(parse_gp_error(res).await);
|
||||
}
|
||||
|
||||
res.text().await.map_err(|err| {
|
||||
@@ -75,21 +90,28 @@ pub async fn parse_gp_response(res: Response) -> anyhow::Result<String, GpError>
|
||||
status,
|
||||
reason: "failed to read response".to_string(),
|
||||
body: "<failed to read response>".to_string(),
|
||||
source: Some(err),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async fn parse_gp_error(res: Response) -> (String, String) {
|
||||
async fn parse_gp_error(res: Response) -> GpError {
|
||||
let status = res.status();
|
||||
let reason = res
|
||||
.headers()
|
||||
.get("x-private-pan-globalprotect")
|
||||
.map_or_else(|| "<none>", |v| v.to_str().unwrap_or("<invalid header>"))
|
||||
.to_string();
|
||||
|
||||
let res = res.text().await.map_or_else(
|
||||
|_| "<failed to read response>".to_string(),
|
||||
|v| if v.is_empty() { "<empty>".to_string() } else { v },
|
||||
);
|
||||
let (body, source) = match res.text().await {
|
||||
Ok(body) => (if body.is_empty() { "<empty>".to_string() } else { body }, None),
|
||||
Err(error) => ("<failed to read response>".to_string(), Some(error)),
|
||||
};
|
||||
|
||||
(reason, res)
|
||||
GpError {
|
||||
status,
|
||||
reason,
|
||||
body,
|
||||
source,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
use security_framework::{import_export::Pkcs12ImportOptions, os::macos::keychain::CreateOptions};
|
||||
|
||||
use super::request::RequestIdentityError;
|
||||
|
||||
pub(super) fn ensure_complete(bytes: &[u8], password: &str) -> anyhow::Result<()> {
|
||||
// native-tls assumes a successful import has a last item with an identity.
|
||||
// Incomplete archives violate that assumption and panic. Inspect them first
|
||||
// in a private temporary keychain, never the user's default keychain.
|
||||
let directory = tempfile::tempdir()?;
|
||||
let keychain = CreateOptions::new()
|
||||
.password(&uuid::Uuid::new_v4().to_string())
|
||||
.create(directory.path().join("identity.keychain"))?;
|
||||
if let Ok(imports) = Pkcs12ImportOptions::new()
|
||||
.keychain(keychain)
|
||||
.passphrase(password)
|
||||
.import(bytes)
|
||||
&& !imports.last().is_some_and(|item| item.identity.is_some())
|
||||
{
|
||||
return Err(RequestIdentityError::IncompletePkcs12.into());
|
||||
}
|
||||
// Leave failed imports to reqwest so password errors retain their existing
|
||||
// classification and native error chain.
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
use openssl::pkcs12::Pkcs12;
|
||||
|
||||
use super::request::RequestIdentityError;
|
||||
|
||||
pub(super) fn ensure_complete(bytes: &[u8], password: &str) -> anyhow::Result<()> {
|
||||
// Parse errors belong to the existing native TLS importer. A successful parse
|
||||
// lets us report incomplete archives without suggesting a password change.
|
||||
if let Ok(archive) = Pkcs12::from_der(bytes).and_then(|archive| archive.parse2(password))
|
||||
&& (archive.pkey.is_none() || archive.cert.is_none())
|
||||
{
|
||||
return Err(RequestIdentityError::IncompletePkcs12.into());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
use std::sync::RwLock;
|
||||
|
||||
use redact_engine::{Pattern, Redaction as RedactEngine};
|
||||
use regex::Regex;
|
||||
use url::{Url, form_urlencoded};
|
||||
|
||||
pub struct Redaction {
|
||||
redact_engine: RwLock<Option<RedactEngine>>,
|
||||
patterns: RwLock<Vec<Regex>>,
|
||||
}
|
||||
|
||||
impl Default for Redaction {
|
||||
@@ -16,56 +15,45 @@ impl Default for Redaction {
|
||||
|
||||
impl Redaction {
|
||||
pub fn new() -> Self {
|
||||
let redact_engine = RedactEngine::custom("[**********]").add_pattern(Pattern {
|
||||
test: Regex::new("(((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4})").unwrap(),
|
||||
group: 1,
|
||||
});
|
||||
|
||||
Self {
|
||||
redact_engine: RwLock::new(Some(redact_engine)),
|
||||
patterns: RwLock::new(vec![
|
||||
Regex::new("(((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4})").unwrap(),
|
||||
]),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_value(&self, text: &str) -> anyhow::Result<()> {
|
||||
let mut redact_engine = self
|
||||
.redact_engine
|
||||
.write()
|
||||
.map_err(|_| anyhow::anyhow!("Failed to acquire write lock on redact engine"))?;
|
||||
|
||||
*redact_engine = Some(
|
||||
redact_engine
|
||||
.take()
|
||||
.ok_or_else(|| anyhow::anyhow!("Failed to take redact engine"))?
|
||||
.add_value(text)?,
|
||||
);
|
||||
|
||||
Ok(())
|
||||
self.add_values(&[text])
|
||||
}
|
||||
|
||||
pub fn add_values(&self, texts: &[&str]) -> anyhow::Result<()> {
|
||||
let mut redact_engine = self
|
||||
.redact_engine
|
||||
let patterns = texts
|
||||
.iter()
|
||||
.map(|text| Regex::new(®ex::escape(text)))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
self
|
||||
.patterns
|
||||
.write()
|
||||
.map_err(|_| anyhow::anyhow!("Failed to acquire write lock on redact engine"))?;
|
||||
|
||||
*redact_engine = Some(
|
||||
redact_engine
|
||||
.take()
|
||||
.ok_or_else(|| anyhow::anyhow!("Failed to take redact engine"))?
|
||||
.add_values(texts.to_vec())?,
|
||||
);
|
||||
.map_err(|_| anyhow::anyhow!("Failed to acquire write lock on redaction patterns"))?
|
||||
.extend(patterns);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn redact_str(&self, text: &str) -> String {
|
||||
self
|
||||
.redact_engine
|
||||
let patterns = self
|
||||
.patterns
|
||||
.read()
|
||||
.expect("Failed to acquire read lock on redact engine")
|
||||
.as_ref()
|
||||
.expect("Failed to get redact engine")
|
||||
.redact_str(text)
|
||||
.expect("Failed to acquire read lock on redaction patterns");
|
||||
let mut redacted = text.to_owned();
|
||||
// Match the original text, then replace in registration order. Matching the
|
||||
// replacements would change how overlapping values are redacted.
|
||||
for pattern in patterns.iter() {
|
||||
for matched in pattern.find_iter(text) {
|
||||
redacted = redacted.replacen(matched.as_str(), "[**********]", 1);
|
||||
}
|
||||
}
|
||||
redacted
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +168,38 @@ fn redact_query(query: Option<&str>) -> Option<String> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn redacts_repeated_ipv4_addresses() {
|
||||
assert_eq!(
|
||||
Redaction::new().redact_str("from 192.0.2.1 to 198.51.100.9, then 192.0.2.1"),
|
||||
"from [**********] to [**********], then [**********]"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn registered_values_are_literal_and_support_unicode() {
|
||||
let redaction = Redaction::new();
|
||||
redaction.add_values(&["a.b+$[x]", "秘密🔑"]).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
redaction.redact_str("a.b+$[x] 秘密🔑 a.b+$[x] aXb"),
|
||||
"[**********] [**********] [**********] aXb"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overlapping_values_keep_registration_order() {
|
||||
let redaction = Redaction::new();
|
||||
redaction.add_values(&["foobar", "foo"]).unwrap();
|
||||
|
||||
assert_eq!(redaction.redact_str("foobar foo"), "[**********] [**********]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unicode_word_characters_preserve_ipv4_boundaries() {
|
||||
assert_eq!(Redaction::new().redact_str("192.0.2.1é"), "192.0.2.1é");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_should_not_redact_value() {
|
||||
let text = "fo";
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use std::{fmt, fs, io::Write, path::Path, sync::Arc};
|
||||
|
||||
use anyhow::{Context, ensure};
|
||||
use openssl::{pkey::PKey, x509::X509};
|
||||
use reqwest::Identity;
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
use super::{identity_encoding, pkcs12_identity};
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum RequestIdentityError {
|
||||
#[error("Failed to find the private key")]
|
||||
@@ -13,6 +14,24 @@ pub enum RequestIdentityError {
|
||||
NoPassphrase(&'static str),
|
||||
#[error("Failed to decrypt private key")]
|
||||
DecryptError(&'static str),
|
||||
#[error(
|
||||
"Unsupported private key encryption. Convert the key to modern PKCS#8 using PBES2 with AES before importing it"
|
||||
)]
|
||||
UnsupportedEncryption,
|
||||
#[error(
|
||||
"Could not convert the legacy private key with OpenSSL: {0}. Convert the key to modern PKCS#8 using PBES2 with AES before importing it"
|
||||
)]
|
||||
LegacyKeyConversion(&'static str),
|
||||
#[error("Unsupported private key format. Convert the key to PKCS#8 before importing it")]
|
||||
UnsupportedKeyFormat,
|
||||
#[error("Invalid private key")]
|
||||
InvalidKey,
|
||||
#[error("Invalid certificate or certificate chain")]
|
||||
InvalidCertificate,
|
||||
#[error("The PKCS#12 file must contain both a client certificate and its private key")]
|
||||
IncompletePkcs12,
|
||||
#[error("Could not open the PKCS#12 certificate. Check the password and certificate file")]
|
||||
InvalidPkcs12(#[source] reqwest::Error),
|
||||
}
|
||||
|
||||
/// Loaded once by the authentication owner. PEM keys are decrypted once; PKCS#12
|
||||
@@ -41,37 +60,17 @@ impl fmt::Debug for ClientIdentity {
|
||||
impl ClientIdentity {
|
||||
pub fn load(certificate: &str, key: Option<&str>, passphrase: Option<&str>) -> anyhow::Result<Self> {
|
||||
let certificate_bytes = read_identity_file(certificate)?;
|
||||
if certificate.ends_with(".p12") || certificate.ends_with(".pfx") {
|
||||
let passphrase = passphrase.ok_or(RequestIdentityError::NoPassphrase("PKCS#12"))?;
|
||||
return Self::from_data(certificate_bytes, None, Some(passphrase));
|
||||
let extension = Path::new(certificate).extension().and_then(|value| value.to_str());
|
||||
if extension.is_some_and(|value| value.eq_ignore_ascii_case("p12") || value.eq_ignore_ascii_case("pfx")) {
|
||||
return Self::from_data(certificate_bytes, None, passphrase);
|
||||
}
|
||||
let key_bytes = match key {
|
||||
Some(path) => read_identity_file(path)?,
|
||||
None => certificate_bytes.clone(),
|
||||
};
|
||||
// Keep the previous first-private-key rule: unrelated later blocks must not
|
||||
// change which key is selected or whether the caller is prompted.
|
||||
let key = pem::parse_many(&*key_bytes)?
|
||||
.into_iter()
|
||||
.find(|pem| pem.tag().ends_with("PRIVATE KEY"))
|
||||
.ok_or(RequestIdentityError::NoKey)?;
|
||||
let key_pem = Zeroizing::new(pem::encode(&key));
|
||||
let key = if key.tag().ends_with("ENCRYPTED PRIVATE KEY") {
|
||||
let passphrase = passphrase.ok_or(RequestIdentityError::NoPassphrase("PEM"))?;
|
||||
let key = PKey::private_key_from_pem_passphrase(key_pem.as_bytes(), passphrase.as_bytes())
|
||||
.map_err(|_| RequestIdentityError::DecryptError("PEM"))?;
|
||||
Zeroizing::new(key.private_key_to_pem_pkcs8()?)
|
||||
} else {
|
||||
Zeroizing::new(key_pem.as_bytes().to_vec())
|
||||
};
|
||||
// Strip private-key blocks before importing the certificate chain: macOS
|
||||
// otherwise imports the same key twice for combined PEM files.
|
||||
let mut certificate = Zeroizing::new(Vec::new());
|
||||
for cert in X509::stack_from_pem(&certificate_bytes)? {
|
||||
certificate.extend(cert.to_pem()?);
|
||||
}
|
||||
let identity = Identity::from_pkcs8_pem(&certificate, &key)?;
|
||||
let key = Zeroizing::new(PKey::private_key_from_pem(&key)?.private_key_to_pem_pkcs8()?);
|
||||
let key = identity_encoding::private_key(&key_bytes, passphrase)?;
|
||||
let certificate = identity_encoding::certificate_chain(&certificate_bytes)?;
|
||||
let identity = pem_request_identity(&certificate, &key)?;
|
||||
Ok(Self {
|
||||
material: Arc::new(IdentityMaterial {
|
||||
certificate,
|
||||
@@ -90,12 +89,21 @@ impl ClientIdentity {
|
||||
passphrase: Option<&str>,
|
||||
) -> anyhow::Result<Self> {
|
||||
let (identity, passphrase) = match &key {
|
||||
Some(key) => (Identity::from_pkcs8_pem(&certificate, key)?, None),
|
||||
Some(key) => (pem_request_identity(&certificate, key)?, None),
|
||||
None => {
|
||||
let passphrase = passphrase.ok_or(RequestIdentityError::NoPassphrase("PKCS#12"))?;
|
||||
pkcs12_identity::ensure_complete(&certificate, passphrase.unwrap_or_default())?;
|
||||
// A blank settings field is stored as None. Try the empty password so
|
||||
// passwordless archives work, but keep prompting for protected ones.
|
||||
let identity = Identity::from_pkcs12_der(&certificate, passphrase.unwrap_or_default()).map_err(|error| {
|
||||
if passphrase.is_none() {
|
||||
RequestIdentityError::NoPassphrase("PKCS#12")
|
||||
} else {
|
||||
RequestIdentityError::InvalidPkcs12(error)
|
||||
}
|
||||
})?;
|
||||
(
|
||||
Identity::from_pkcs12_der(&certificate, passphrase)?,
|
||||
Some(Zeroizing::new(passphrase.to_owned())),
|
||||
identity,
|
||||
Some(Zeroizing::new(passphrase.unwrap_or_default().to_owned())),
|
||||
)
|
||||
}
|
||||
};
|
||||
@@ -152,6 +160,20 @@ impl ClientIdentityFiles {
|
||||
}
|
||||
}
|
||||
|
||||
fn pem_request_identity(certificate: &[u8], key: &[u8]) -> anyhow::Result<Identity> {
|
||||
let error_context =
|
||||
"Client certificate and private key cannot be used together. Check that the private key matches the certificate";
|
||||
let identity = Identity::from_pkcs8_pem(certificate, key).context(error_context)?;
|
||||
// Native TLS may defer the certificate/key match check until connector creation.
|
||||
// Build the same client used for requests without making a network connection.
|
||||
reqwest::Client::builder()
|
||||
.no_proxy()
|
||||
.identity(identity.clone())
|
||||
.build()
|
||||
.context(error_context)?;
|
||||
Ok(identity)
|
||||
}
|
||||
|
||||
fn read_identity_file(path: &str) -> anyhow::Result<Zeroizing<Vec<u8>>> {
|
||||
Ok(Zeroizing::new(
|
||||
fs::read(path).context("Failed to read client identity")?,
|
||||
@@ -189,50 +211,15 @@ pub fn create_identity(cert: &str, key: Option<&str>, passphrase: Option<&str>)
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use openssl::pkcs12::Pkcs12;
|
||||
|
||||
fn generated_identity() -> (Vec<u8>, Vec<u8>) {
|
||||
use openssl::{asn1::Asn1Time, hash::MessageDigest, rsa::Rsa, x509::X509NameBuilder};
|
||||
let key = PKey::from_rsa(Rsa::generate(2048).unwrap()).unwrap();
|
||||
let mut name = X509NameBuilder::new().unwrap();
|
||||
name.append_entry_by_text("CN", "identity-fixture").unwrap();
|
||||
let name = name.build();
|
||||
let mut certificate = X509::builder().unwrap();
|
||||
certificate.set_version(2).unwrap();
|
||||
certificate.set_subject_name(&name).unwrap();
|
||||
certificate.set_issuer_name(&name).unwrap();
|
||||
certificate.set_pubkey(&key).unwrap();
|
||||
certificate
|
||||
.set_not_before(&Asn1Time::days_from_now(0).unwrap())
|
||||
.unwrap();
|
||||
certificate.set_not_after(&Asn1Time::days_from_now(1).unwrap()).unwrap();
|
||||
certificate.sign(&key, MessageDigest::sha256()).unwrap();
|
||||
(
|
||||
certificate.build().to_pem().unwrap(),
|
||||
key.private_key_to_pem_pkcs8().unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pem_uses_first_private_key_without_prompting_for_later_encrypted_keys() {
|
||||
let (certificate, key) = generated_identity();
|
||||
let encrypted = PKey::private_key_from_pem(&key)
|
||||
.unwrap()
|
||||
.private_key_to_pem_pkcs8_passphrase(openssl::symm::Cipher::aes_256_cbc(), b"unused")
|
||||
.unwrap();
|
||||
let mut source = tempfile::NamedTempFile::new().unwrap();
|
||||
source.write_all(&certificate).unwrap();
|
||||
source.write_all(&key).unwrap();
|
||||
source.write_all(&encrypted).unwrap();
|
||||
let identity = ClientIdentity::load(source.path().to_str().unwrap(), None, None).unwrap();
|
||||
assert_eq!(identity.key_data().unwrap(), key);
|
||||
}
|
||||
const CERTIFICATE: &[u8] = include_bytes!("../../tests/files/client-identity/rsa-cert.pem");
|
||||
const KEY: &[u8] = include_bytes!("../../tests/files/client-identity/rsa-pkcs8.pem");
|
||||
const ENCRYPTED_KEY: &[u8] = include_bytes!("../../tests/files/client-identity/rsa-pbes2-sha256.pem");
|
||||
|
||||
#[test]
|
||||
fn pem_without_key_reports_missing_key_even_with_passphrase() {
|
||||
let (certificate, _) = generated_identity();
|
||||
let mut source = tempfile::NamedTempFile::new().unwrap();
|
||||
source.write_all(&certificate).unwrap();
|
||||
source.write_all(CERTIFICATE).unwrap();
|
||||
for passphrase in [None, Some("unused")] {
|
||||
let error = ClientIdentity::load(source.path().to_str().unwrap(), None, passphrase).unwrap_err();
|
||||
assert!(matches!(
|
||||
@@ -244,249 +231,57 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn local_identity_loading_is_not_limited_by_service_message_size() {
|
||||
let (certificate, key) = generated_identity();
|
||||
let mut source = tempfile::NamedTempFile::new().unwrap();
|
||||
source.write_all(&certificate).unwrap();
|
||||
source.write_all(&key).unwrap();
|
||||
source.write_all(CERTIFICATE).unwrap();
|
||||
source.write_all(KEY).unwrap();
|
||||
source.write_all(&vec![b'\n'; 33 * 1024]).unwrap();
|
||||
let identity = ClientIdentity::load(source.path().to_str().unwrap(), None, None).unwrap();
|
||||
assert_eq!(identity.certificate_data(), certificate);
|
||||
assert_eq!(identity.key_data().unwrap(), key);
|
||||
assert_eq!(identity.certificate_data(), CERTIFICATE);
|
||||
assert_eq!(identity.key_data().unwrap(), KEY);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pem_passphrases_preserve_prompt_errors_and_accept_separate_keys() {
|
||||
let (certificate, key) = generated_identity();
|
||||
let mut cert_file = tempfile::NamedTempFile::new().unwrap();
|
||||
cert_file.write_all(&certificate).unwrap();
|
||||
let mut key_file = tempfile::NamedTempFile::new().unwrap();
|
||||
let encrypted = PKey::private_key_from_pem(&key)
|
||||
.unwrap()
|
||||
.private_key_to_pem_pkcs8_passphrase(openssl::symm::Cipher::aes_256_cbc(), b"correct")
|
||||
.unwrap();
|
||||
key_file.write_all(&encrypted).unwrap();
|
||||
let cert = cert_file.path().to_str().unwrap();
|
||||
let key_path = Some(key_file.path().to_str().unwrap());
|
||||
for (passphrase, missing) in [(None, true), (Some("wrong"), false)] {
|
||||
let error = ClientIdentity::load(cert, key_path, passphrase).unwrap_err();
|
||||
match error.downcast_ref::<RequestIdentityError>().unwrap() {
|
||||
RequestIdentityError::NoPassphrase("PEM") => assert!(missing),
|
||||
RequestIdentityError::DecryptError("PEM") => assert!(!missing),
|
||||
other => panic!("Unexpected identity error: {other}"),
|
||||
fn create_identity_preserves_password_errors_and_builds_a_native_request_client() {
|
||||
let mut source = tempfile::NamedTempFile::new().unwrap();
|
||||
source.write_all(CERTIFICATE).unwrap();
|
||||
source.write_all(ENCRYPTED_KEY).unwrap();
|
||||
for (password, missing) in [(None, true), (Some("wrong"), false)] {
|
||||
let error = create_identity(source.path().to_str().unwrap(), None, password).unwrap_err();
|
||||
match error.downcast_ref::<RequestIdentityError>() {
|
||||
Some(RequestIdentityError::NoPassphrase("PEM")) => assert!(missing),
|
||||
Some(RequestIdentityError::DecryptError("PEM")) => assert!(!missing),
|
||||
other => panic!("Unexpected identity error: {other:?}"),
|
||||
}
|
||||
}
|
||||
let loaded = ClientIdentity::load(cert, key_path, Some("correct")).unwrap();
|
||||
assert_eq!(loaded.key_data().unwrap(), key);
|
||||
fs::write(key_file.path(), &key).unwrap();
|
||||
for passphrase in [None, Some("ignored for unencrypted key")] {
|
||||
assert_eq!(
|
||||
ClientIdentity::load(cert, key_path, passphrase)
|
||||
.unwrap()
|
||||
.key_data()
|
||||
.unwrap(),
|
||||
key
|
||||
);
|
||||
}
|
||||
let identity = create_identity(source.path().to_str().unwrap(), None, Some("fixture-password")).unwrap();
|
||||
drop(source);
|
||||
reqwest::Client::builder().identity(identity).build().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn loaded_identity_survives_original_file_replacement_and_owns_private_files() {
|
||||
fn unencrypted_key_ignores_unused_password_and_archive_owned_file_is_private() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let (certificate, key) = generated_identity();
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let source = directory.path().join("combined.pem");
|
||||
let mut combined = certificate.clone();
|
||||
combined.extend(&key);
|
||||
fs::write(&source, &combined).unwrap();
|
||||
let identity = ClientIdentity::load(source.to_str().unwrap(), None, None).unwrap();
|
||||
fs::write(&source, "changed after authentication").unwrap();
|
||||
assert_eq!(identity.certificate_data(), certificate);
|
||||
assert_eq!(identity.key_data().unwrap(), key);
|
||||
assert!(!format!("{identity:?}").contains("PRIVATE KEY"));
|
||||
let files = identity.write_files(Some(directory.path())).unwrap();
|
||||
let certificate_path = files.certificate().to_owned();
|
||||
let key_path = files.key().unwrap().to_owned();
|
||||
assert_eq!(fs::read(&certificate_path).unwrap(), certificate);
|
||||
assert_eq!(fs::read(&key_path).unwrap(), key);
|
||||
assert_eq!(fs::metadata(&key_path).unwrap().permissions().mode() & 0o777, 0o600);
|
||||
let identity = ClientIdentity::from_data(
|
||||
Zeroizing::new(CERTIFICATE.to_vec()),
|
||||
Some(Zeroizing::new(KEY.to_vec())),
|
||||
Some("unused password"),
|
||||
)
|
||||
.unwrap();
|
||||
assert!(identity.key_password().is_none());
|
||||
let archive = include_bytes!("../../tests/files/client-identity/modern.p12").to_vec();
|
||||
let identity = ClientIdentity::from_data(Zeroizing::new(archive), None, Some("fixture-password")).unwrap();
|
||||
let files = identity.write_files(None).unwrap();
|
||||
let path = files.certificate().to_owned();
|
||||
assert!(path.ends_with(".p12"));
|
||||
assert!(files.key().is_none());
|
||||
assert_eq!(fs::metadata(&path).unwrap().permissions().mode() & 0o777, 0o600);
|
||||
drop(files);
|
||||
assert!(!Path::new(&certificate_path).exists());
|
||||
assert!(!Path::new(&key_path).exists());
|
||||
// The request identity remains valid after its original files disappear.
|
||||
fs::remove_file(&source).unwrap();
|
||||
assert!(!Path::new(&path).exists());
|
||||
reqwest::Client::builder()
|
||||
.identity(identity.request_identity())
|
||||
.build()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pkcs12_preserves_original_data_password_and_owned_native_files() {
|
||||
let (certificate, key) = generated_identity();
|
||||
let certificate = X509::from_pem(&certificate).unwrap();
|
||||
let key = PKey::private_key_from_pem(&key).unwrap();
|
||||
let mut builder = Pkcs12::builder();
|
||||
builder.name("identity-fixture").pkey(&key).cert(&certificate);
|
||||
let encoded = builder.build2("fixture-password").unwrap().to_der().unwrap();
|
||||
for suffix in [".p12", ".pfx"] {
|
||||
let mut source = tempfile::Builder::new().suffix(suffix).tempfile().unwrap();
|
||||
source.write_all(&encoded).unwrap();
|
||||
let path = source.path().to_str().unwrap();
|
||||
assert!(ClientIdentity::load(path, None, None).is_err());
|
||||
assert!(ClientIdentity::load(path, None, Some("wrong")).is_err());
|
||||
// PKCS#12 has always ignored a separately configured key path.
|
||||
let identity = ClientIdentity::load(path, Some("missing-key-file"), Some("fixture-password")).unwrap();
|
||||
fs::write(source.path(), b"replaced after login").unwrap();
|
||||
assert_eq!(identity.certificate_data(), encoded);
|
||||
assert!(identity.key_data().is_none());
|
||||
assert_eq!(identity.key_password(), Some("fixture-password"));
|
||||
assert!(!format!("{identity:?}").contains("fixture-password"));
|
||||
let files = identity.write_files(None).unwrap();
|
||||
assert!(files.certificate().ends_with(".p12"));
|
||||
assert!(files.key().is_none());
|
||||
ClientIdentity::load(files.certificate(), files.key(), identity.key_password()).unwrap();
|
||||
let owned_path = files.certificate().to_owned();
|
||||
drop(files);
|
||||
assert!(!Path::new(&owned_path).exists());
|
||||
}
|
||||
let empty_password = builder.build2("").unwrap().to_der().unwrap();
|
||||
// Empty-password support varies by native backend and PKCS#12 algorithms.
|
||||
// Match the previous native import instead of introducing another parser.
|
||||
let previously_accepted = Identity::from_pkcs12_der(&empty_password, "").is_ok();
|
||||
assert_eq!(
|
||||
ClientIdentity::from_data(Zeroizing::new(empty_password), None, Some("")).is_ok(),
|
||||
previously_accepted
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pkcs12_retains_chain_without_reordering_or_reencoding() {
|
||||
use openssl::{
|
||||
asn1::Asn1Time,
|
||||
hash::MessageDigest,
|
||||
rsa::Rsa,
|
||||
stack::Stack,
|
||||
x509::{X509NameBuilder, extension::BasicConstraints},
|
||||
};
|
||||
fn certificate(
|
||||
name: &str,
|
||||
parent: Option<(&X509, &PKey<openssl::pkey::Private>)>,
|
||||
ca: bool,
|
||||
) -> (X509, PKey<openssl::pkey::Private>) {
|
||||
let key = PKey::from_rsa(Rsa::generate(2048).unwrap()).unwrap();
|
||||
let mut subject = X509NameBuilder::new().unwrap();
|
||||
subject.append_entry_by_text("CN", name).unwrap();
|
||||
let subject = subject.build();
|
||||
let mut cert = X509::builder().unwrap();
|
||||
cert.set_version(2).unwrap();
|
||||
let serial = openssl::bn::BigNum::from_u32(name.len() as u32)
|
||||
.unwrap()
|
||||
.to_asn1_integer()
|
||||
.unwrap();
|
||||
cert.set_serial_number(&serial).unwrap();
|
||||
cert.set_subject_name(&subject).unwrap();
|
||||
cert
|
||||
.set_issuer_name(parent.map(|(cert, _)| cert.subject_name()).unwrap_or(&subject))
|
||||
.unwrap();
|
||||
cert.set_pubkey(&key).unwrap();
|
||||
cert.set_not_before(&Asn1Time::days_from_now(0).unwrap()).unwrap();
|
||||
cert.set_not_after(&Asn1Time::days_from_now(1).unwrap()).unwrap();
|
||||
if ca {
|
||||
cert
|
||||
.append_extension(BasicConstraints::new().critical().ca().build().unwrap())
|
||||
.unwrap();
|
||||
}
|
||||
cert
|
||||
.sign(parent.map(|(_, key)| key).unwrap_or(&key), MessageDigest::sha256())
|
||||
.unwrap();
|
||||
(cert.build(), key)
|
||||
}
|
||||
let (root, root_key) = certificate("root", None, true);
|
||||
let (intermediate, intermediate_key) = certificate("intermediate", Some((&root, &root_key)), true);
|
||||
let (leaf, key) = certificate("client", Some((&intermediate, &intermediate_key)), false);
|
||||
// This is the reverse CA stack consumed by the previous native-tls path.
|
||||
let mut ca = Stack::new().unwrap();
|
||||
ca.push(root.clone()).unwrap();
|
||||
ca.push(intermediate.clone()).unwrap();
|
||||
let mut builder = Pkcs12::builder();
|
||||
builder.name("chain-fixture").pkey(&key).cert(&leaf).ca(ca);
|
||||
let encoded = builder.build2("fixture-password").unwrap().to_der().unwrap();
|
||||
let mut source = tempfile::Builder::new().suffix(".p12").tempfile().unwrap();
|
||||
source.write_all(&encoded).unwrap();
|
||||
let identity = ClientIdentity::load(source.path().to_str().unwrap(), None, Some("fixture-password")).unwrap();
|
||||
assert_eq!(identity.certificate_data(), encoded);
|
||||
assert!(identity.key_data().is_none());
|
||||
ClientIdentity::from_data(
|
||||
Zeroizing::new(identity.certificate_data().to_vec()),
|
||||
None,
|
||||
identity.key_password(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_identity_from_pem_requires_passphrase() {
|
||||
let cert = "tests/files/badssl.com-client.pem";
|
||||
let identity = create_identity(cert, None, None);
|
||||
|
||||
assert!(identity.is_err());
|
||||
assert!(identity.unwrap_err().to_string().contains("No passphrase provided"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn create_identity_from_pem_with_passphrase() {
|
||||
let cert = "tests/files/badssl.com-client.pem";
|
||||
let passphrase = "badssl.com";
|
||||
|
||||
let identity = create_identity(cert, None, Some(passphrase));
|
||||
|
||||
assert!(identity.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn create_identity_from_pem_unencrypted_key() {
|
||||
let cert = "tests/files/badssl.com-client-unencrypted.pem";
|
||||
let identity = create_identity(cert, None, None);
|
||||
println!("{:?}", identity);
|
||||
|
||||
assert!(identity.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn create_identity_from_pem_cert_and_encrypted_key() {
|
||||
let cert = "tests/files/badssl.com-client.pem";
|
||||
let key = "tests/files/badssl.com-client.pem";
|
||||
let passphrase = "badssl.com";
|
||||
|
||||
let identity = create_identity(cert, Some(key), Some(passphrase));
|
||||
|
||||
assert!(identity.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_identity_from_pem_cert_and_encrypted_key_no_passphrase() {
|
||||
let cert = "tests/files/badssl.com-client.pem";
|
||||
let key = "tests/files/badssl.com-client.pem";
|
||||
|
||||
let identity = create_identity(cert, Some(key), None);
|
||||
|
||||
assert!(identity.is_err());
|
||||
assert!(identity.unwrap_err().to_string().contains("No passphrase provided"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn create_identity_from_pem_cert_and_unencrypted_key() {
|
||||
let cert = "tests/files/badssl.com-client.pem";
|
||||
let key = "tests/files/badssl.com-client-unencrypted.pem";
|
||||
|
||||
let identity = create_identity(cert, Some(key), None);
|
||||
|
||||
assert!(identity.is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
use pkcs8::SecretDocument;
|
||||
|
||||
use super::{identity_encoding::TraditionalKeyFormat, request::RequestIdentityError};
|
||||
|
||||
pub(super) fn normalize(
|
||||
_bytes: &[u8],
|
||||
format: TraditionalKeyFormat,
|
||||
_passphrase: Option<&str>,
|
||||
) -> anyhow::Result<SecretDocument> {
|
||||
Err(
|
||||
match format {
|
||||
TraditionalKeyFormat::EncryptedPem => RequestIdentityError::UnsupportedEncryption,
|
||||
TraditionalKeyFormat::PlainPem | TraditionalKeyFormat::Sec1Der => RequestIdentityError::UnsupportedKeyFormat,
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
use openssl::{
|
||||
error::ErrorStack,
|
||||
pkey::{Id, PKey},
|
||||
};
|
||||
use pkcs8::SecretDocument;
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
use super::{identity_encoding::TraditionalKeyFormat, request::RequestIdentityError};
|
||||
|
||||
pub(super) fn normalize(
|
||||
bytes: &[u8],
|
||||
format: TraditionalKeyFormat,
|
||||
passphrase: Option<&str>,
|
||||
) -> anyhow::Result<SecretDocument> {
|
||||
let key = match format {
|
||||
TraditionalKeyFormat::Sec1Der => PKey::private_key_from_der(bytes),
|
||||
TraditionalKeyFormat::PlainPem => PKey::private_key_from_pem_passphrase(bytes, b""),
|
||||
TraditionalKeyFormat::EncryptedPem => {
|
||||
let passphrase = passphrase.ok_or(RequestIdentityError::NoPassphrase("PEM"))?;
|
||||
anyhow::ensure!(
|
||||
!passphrase.as_bytes().contains(&0),
|
||||
"Private key passphrases containing NUL are not supported"
|
||||
);
|
||||
PKey::private_key_from_pem_passphrase(bytes, passphrase.as_bytes())
|
||||
}
|
||||
}
|
||||
.map_err(import_error)?;
|
||||
if !matches!(key.id(), Id::RSA | Id::EC) {
|
||||
return Err(RequestIdentityError::UnsupportedKeyFormat.into());
|
||||
}
|
||||
let der = Zeroizing::new(
|
||||
key
|
||||
.private_key_to_pkcs8()
|
||||
.map_err(|_| RequestIdentityError::InvalidKey)?,
|
||||
);
|
||||
Ok(SecretDocument::try_from(der.as_slice()).map_err(|_| RequestIdentityError::InvalidKey)?)
|
||||
}
|
||||
|
||||
fn import_error(error: ErrorStack) -> RequestIdentityError {
|
||||
// Inspect only known backend reasons. Never expose the native error stack or
|
||||
// turn an unclassified decoder failure into a password retry loop.
|
||||
if error.errors().iter().any(|error| error.reason() == Some("bad decrypt")) {
|
||||
RequestIdentityError::DecryptError("PEM")
|
||||
} else if error.errors().iter().any(|error| error.reason() == Some("unsupported")) {
|
||||
RequestIdentityError::UnsupportedEncryption
|
||||
} else {
|
||||
RequestIdentityError::InvalidKey
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,708 @@
|
||||
//! Public identity compatibility and native import behavior.
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
use gpapi::utils::request::{ClientIdentity, RequestIdentityError};
|
||||
|
||||
const PASSWORD: &str = "fixture-password";
|
||||
|
||||
fn fixture(name: &str) -> PathBuf {
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("tests/files/client-identity")
|
||||
.join(name)
|
||||
}
|
||||
|
||||
fn load(certificate: &str, key: &str, password: Option<&str>) -> anyhow::Result<ClientIdentity> {
|
||||
ClientIdentity::load(
|
||||
fixture(certificate).to_str().unwrap(),
|
||||
Some(fixture(key).to_str().unwrap()),
|
||||
password,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rsa_pkcs8_loads_without_a_password() {
|
||||
let identity = load("rsa-cert.pem", "rsa-pkcs8.pem", None).unwrap();
|
||||
assert_eq!(identity.certificate_data(), fs::read(fixture("rsa-cert.pem")).unwrap());
|
||||
assert_eq!(
|
||||
identity.key_data().unwrap(),
|
||||
fs::read(fixture("rsa-pkcs8.pem")).unwrap()
|
||||
);
|
||||
assert!(identity.key_password().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ec_pkcs8_records_native_import_compatibility() {
|
||||
let result = load("ec-cert.pem", "ec-pkcs8.pem", None);
|
||||
if cfg!(target_os = "macos") {
|
||||
// Apple native-tls import currently rejects this P-256 PKCS#8 fixture.
|
||||
assert!(
|
||||
result
|
||||
.unwrap_err()
|
||||
.downcast_ref::<reqwest::Error>()
|
||||
.unwrap()
|
||||
.is_builder()
|
||||
);
|
||||
} else {
|
||||
assert_eq!(
|
||||
result.unwrap().key_data().unwrap(),
|
||||
fs::read(fixture("ec-pkcs8.pem")).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn encrypted_pkcs8_keys_normalize_to_the_same_private_key() {
|
||||
for (key, expected, certificate) in [
|
||||
("rsa-pbes2-sha1.pem", "rsa-pkcs8.pem", "rsa-cert.pem"),
|
||||
("rsa-pbes2-sha256.pem", "rsa-pkcs8.pem", "rsa-cert.pem"),
|
||||
("rsa-pbes2-aes-128-cbc-sha1.pem", "rsa-pkcs8.pem", "rsa-cert.pem"),
|
||||
("rsa-pbes2-aes-128-cbc-sha256.pem", "rsa-pkcs8.pem", "rsa-cert.pem"),
|
||||
("rsa-pbes2-aes-192-cbc-sha1.pem", "rsa-pkcs8.pem", "rsa-cert.pem"),
|
||||
("rsa-pbes2-aes-192-cbc-sha256.pem", "rsa-pkcs8.pem", "rsa-cert.pem"),
|
||||
("rsa-pbes2-scrypt.pem", "rsa-pkcs8.pem", "rsa-cert.pem"),
|
||||
("ec-pbes2.pem", "ec-pkcs8.pem", "ec-cert.pem"),
|
||||
] {
|
||||
let result = load(certificate, key, Some(PASSWORD));
|
||||
if cfg!(target_os = "macos") && certificate == "ec-cert.pem" {
|
||||
assert!(
|
||||
result
|
||||
.unwrap_err()
|
||||
.downcast_ref::<reqwest::Error>()
|
||||
.unwrap()
|
||||
.is_builder()
|
||||
);
|
||||
} else {
|
||||
let identity = result.unwrap_or_else(|error| panic!("{key}: {error}"));
|
||||
assert_eq!(
|
||||
identity.key_data().unwrap(),
|
||||
fs::read(fixture(expected)).unwrap(),
|
||||
"{key}"
|
||||
);
|
||||
assert!(identity.key_password().is_none());
|
||||
}
|
||||
for (password, missing) in [(None, true), (Some("incorrect"), false)] {
|
||||
let error = load(certificate, key, password).unwrap_err();
|
||||
match error.downcast_ref::<RequestIdentityError>() {
|
||||
Some(RequestIdentityError::NoPassphrase("PEM")) => assert!(missing),
|
||||
Some(RequestIdentityError::DecryptError("PEM")) => assert!(!missing),
|
||||
other => panic!("{key}: unexpected error {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn combined_pem_preserves_the_certificate_chain_and_removes_key_blocks() {
|
||||
let mut chain = fs::read(fixture("rsa-cert.pem")).unwrap();
|
||||
chain.extend(fs::read(fixture("root.pem")).unwrap());
|
||||
let mut combined = chain.clone();
|
||||
let key = fs::read(fixture("rsa-pkcs8.pem")).unwrap();
|
||||
combined.extend(&key);
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let source = directory.path().join("combined.pem");
|
||||
fs::write(&source, combined).unwrap();
|
||||
let identity = ClientIdentity::load(source.to_str().unwrap(), None, None).unwrap();
|
||||
assert_eq!(identity.certificate_data(), chain);
|
||||
assert_eq!(identity.key_data().unwrap(), key);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rsa_pkcs1_normalizes_to_pkcs8_in_separate_and_combined_files() {
|
||||
let certificate = fs::read(fixture("rsa-cert.pem")).unwrap();
|
||||
let expected = fs::read(fixture("rsa-pkcs8.pem")).unwrap();
|
||||
for password in [None, Some("unused")] {
|
||||
let identity = load("rsa-cert.pem", "rsa-pkcs1.pem", password).unwrap();
|
||||
assert_eq!(identity.certificate_data(), certificate);
|
||||
assert_eq!(identity.key_data().unwrap(), expected);
|
||||
assert!(identity.key_password().is_none());
|
||||
}
|
||||
|
||||
let mut combined = certificate.clone();
|
||||
combined.extend(fs::read(fixture("rsa-pkcs1.pem")).unwrap());
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let source = directory.path().join("combined.pem");
|
||||
fs::write(&source, combined).unwrap();
|
||||
let identity = ClientIdentity::load(source.to_str().unwrap(), None, None).unwrap();
|
||||
assert_eq!(identity.certificate_data(), certificate);
|
||||
assert_eq!(identity.key_data().unwrap(), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malformed_rsa_pkcs1_is_rejected_by_native_import() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let source = directory.path().join("invalid-key.pem");
|
||||
fs::write(&source, pem::encode(&pem::Pem::new("RSA PRIVATE KEY", vec![0x30, 0]))).unwrap();
|
||||
let error = ClientIdentity::load(
|
||||
fixture("rsa-cert.pem").to_str().unwrap(),
|
||||
Some(source.to_str().unwrap()),
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(error.downcast_ref::<reqwest::Error>().is_some());
|
||||
}
|
||||
|
||||
fn check_archive(name: &str, password: &str) {
|
||||
let source = fixture(name);
|
||||
let path = source.to_str().unwrap();
|
||||
let identity = ClientIdentity::load(path, None, Some(password)).unwrap();
|
||||
assert_eq!(identity.certificate_data(), fs::read(&source).unwrap());
|
||||
assert!(identity.key_data().is_none());
|
||||
assert_eq!(identity.key_password(), Some(password));
|
||||
let files = identity.write_files(None).unwrap();
|
||||
ClientIdentity::load(files.certificate(), files.key(), identity.key_password()).unwrap();
|
||||
assert!(ClientIdentity::load(path, None, Some("incorrect")).is_err());
|
||||
let error = ClientIdentity::load(path, None, None).unwrap_err();
|
||||
assert!(matches!(
|
||||
error.downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::NoPassphrase("PKCS#12"))
|
||||
));
|
||||
// The MAC is at the end of these fixtures. Change authenticated archive data
|
||||
// (a byte in the friendly name), leaving valid ASN.1 and ciphertext intact.
|
||||
let mut corrupted = fs::read(&source).unwrap();
|
||||
let label = [0, b'f', 0, b'i', 0, b'x', 0, b't', 0, b'u', 0, b'r', 0, b'e'];
|
||||
let offset = corrupted
|
||||
.windows(label.len())
|
||||
.position(|window| window == label)
|
||||
.unwrap();
|
||||
corrupted[offset + 1] = b'F';
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let damaged = directory.path().join("damaged.p12");
|
||||
fs::write(&damaged, corrupted).unwrap();
|
||||
assert!(ClientIdentity::load(damaged.to_str().unwrap(), None, Some(password)).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn incomplete_pkcs12_reports_that_both_certificate_and_key_are_required() {
|
||||
for name in ["certificate-only.pfx", "key-only.pfx"] {
|
||||
let bytes = fs::read(fixture(name)).unwrap();
|
||||
for result in [
|
||||
ClientIdentity::load(fixture(name).to_str().unwrap(), None, Some(PASSWORD)),
|
||||
ClientIdentity::from_data(zeroize::Zeroizing::new(bytes.clone()), None, Some(PASSWORD)),
|
||||
] {
|
||||
let error = result.unwrap_err();
|
||||
assert_eq!(
|
||||
error.to_string(),
|
||||
"The PKCS#12 file must contain both a client certificate and its private key",
|
||||
"{name}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn modern_pkcs12_checks_password_and_archive_integrity() {
|
||||
check_archive("modern.p12", PASSWORD);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pkcs12_password_errors_explain_how_to_recover() {
|
||||
let archive = fs::read(fixture("modern.p12")).unwrap();
|
||||
for password in ["incorrect", ""] {
|
||||
let errors = [
|
||||
ClientIdentity::load(fixture("modern.p12").to_str().unwrap(), None, Some(password)).unwrap_err(),
|
||||
ClientIdentity::from_data(zeroize::Zeroizing::new(archive.clone()), None, Some(password)).unwrap_err(),
|
||||
];
|
||||
for error in errors {
|
||||
assert!(matches!(
|
||||
error.downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::InvalidPkcs12(_))
|
||||
));
|
||||
let message = error.to_string();
|
||||
assert!(message.contains("PKCS#12"), "{message}");
|
||||
assert!(message.contains("password") && message.contains("file"), "{message}");
|
||||
assert!(!format!("{error:?}").contains("incorrect"));
|
||||
assert!(error.chain().any(|cause| cause.is::<reqwest::Error>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
// Apple's native importer rejects this empty-password fixture; its native
|
||||
// compatibility decision is covered by archive_snapshot_and_pfx_preserve_native_import_contract.
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn empty_pkcs12_password_survives_loading_and_transport() {
|
||||
let archive = fs::read(fixture("empty-password.p12")).unwrap();
|
||||
for password in [None, Some("")] {
|
||||
let loaded = ClientIdentity::load(fixture("empty-password.p12").to_str().unwrap(), None, password).unwrap();
|
||||
assert_eq!(loaded.key_password(), Some(""));
|
||||
let restored = ClientIdentity::from_data(zeroize::Zeroizing::new(archive.clone()), None, password).unwrap();
|
||||
assert_eq!(restored.key_password(), Some(""));
|
||||
let files = restored.write_files(None).unwrap();
|
||||
ClientIdentity::load(files.certificate(), files.key(), restored.key_password()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pkcs12_accepts_non_ascii_passwords() {
|
||||
check_archive("unicode-password.p12", "pässword-密码");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_rc2_pkcs12_checks_password_and_archive_integrity() {
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
if std::env::var_os("GP_IDENTITY_LEGACY_TEST_CHILD").is_none() {
|
||||
// OpenSSL providers are process-global. Exercise the existing legacy-mode
|
||||
// configuration in an isolated process, without affecting parallel tests.
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let config = directory.path().join("openssl.cnf");
|
||||
fs::write(&config, gpapi::utils::openssl::openssl_conf()).unwrap();
|
||||
let status = std::process::Command::new(std::env::current_exe().unwrap())
|
||||
.args([
|
||||
"--exact",
|
||||
"legacy_rc2_pkcs12_checks_password_and_archive_integrity",
|
||||
"--nocapture",
|
||||
])
|
||||
.env("OPENSSL_CONF", config)
|
||||
.env("GP_IDENTITY_LEGACY_TEST_CHILD", "1")
|
||||
.status()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
return;
|
||||
}
|
||||
check_archive("legacy-rc2.p12", PASSWORD);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_certificate_and_private_key_data_are_rejected() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let invalid = directory.path().join("invalid.pem");
|
||||
fs::write(&invalid, b"not a certificate or private key").unwrap();
|
||||
assert!(
|
||||
ClientIdentity::load(
|
||||
invalid.to_str().unwrap(),
|
||||
Some(fixture("rsa-pkcs8.pem").to_str().unwrap()),
|
||||
None,
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
let error = ClientIdentity::load(
|
||||
fixture("rsa-cert.pem").to_str().unwrap(),
|
||||
Some(invalid.to_str().unwrap()),
|
||||
None,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(matches!(
|
||||
error.downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::InvalidKey)
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pbes2_legacy_ciphers_remain_supported() {
|
||||
for key in ["rsa-pbes2-des3-sha1.pem", "rsa-pbes2-des3-sha256.pem"] {
|
||||
let identity = load("rsa-cert.pem", key, Some(PASSWORD)).unwrap();
|
||||
assert_eq!(
|
||||
identity.key_data().unwrap(),
|
||||
fs::read(fixture("rsa-pkcs8.pem")).unwrap()
|
||||
);
|
||||
for (password, missing) in [(None, true), (Some("incorrect"), false)] {
|
||||
let error = load("rsa-cert.pem", key, password).unwrap_err();
|
||||
match error.downcast_ref::<RequestIdentityError>() {
|
||||
Some(RequestIdentityError::NoPassphrase("PEM")) => assert!(missing),
|
||||
Some(RequestIdentityError::DecryptError("PEM")) => assert!(!missing),
|
||||
other => panic!("{key}: unexpected error {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_pkcs8_conversion_preserves_the_key_and_password_errors() {
|
||||
let identity = load("rsa-cert.pem", "rsa-pbes1-3des.pem", Some(PASSWORD)).unwrap();
|
||||
assert_eq!(
|
||||
identity.key_data().unwrap(),
|
||||
fs::read(fixture("rsa-pkcs8.pem")).unwrap()
|
||||
);
|
||||
assert!(identity.key_password().is_none());
|
||||
for (password, missing) in [(None, true), (Some("incorrect"), false)] {
|
||||
let error = load("rsa-cert.pem", "rsa-pbes1-3des.pem", password).unwrap_err();
|
||||
match error.downcast_ref::<RequestIdentityError>() {
|
||||
Some(RequestIdentityError::NoPassphrase("PEM")) => assert!(missing),
|
||||
Some(RequestIdentityError::DecryptError("PEM")) => assert!(!missing),
|
||||
other => panic!("unexpected legacy password error: {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn legacy_pkcs8_matches_previous_linux_openssl_processing() {
|
||||
let encrypted = fs::read(fixture("rsa-pbes1-3des.pem")).unwrap();
|
||||
let previous = openssl::pkey::PKey::private_key_from_pem_passphrase(&encrypted, PASSWORD.as_bytes())
|
||||
.unwrap()
|
||||
.private_key_to_pem_pkcs8()
|
||||
.unwrap();
|
||||
let identity = load("rsa-cert.pem", "rsa-pbes1-3des.pem", Some(PASSWORD)).unwrap();
|
||||
assert_eq!(identity.key_data().unwrap(), previous);
|
||||
assert!(openssl::pkey::PKey::private_key_from_pem_passphrase(&encrypted, b"incorrect").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_pkcs8_converter_failures_are_terminal_and_modern_keys_need_no_executable() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
const CHILD: &str = "GP_LEGACY_CONVERTER_TEST";
|
||||
if let Ok(case) = std::env::var(CHILD) {
|
||||
let started = std::time::Instant::now();
|
||||
let error = load("rsa-cert.pem", "rsa-pbes1-3des.pem", Some(PASSWORD)).unwrap_err();
|
||||
assert!(
|
||||
started.elapsed() < std::time::Duration::from_secs(12),
|
||||
"conversion exceeded its deadline"
|
||||
);
|
||||
assert!(
|
||||
matches!(
|
||||
error.downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::LegacyKeyConversion(_))
|
||||
),
|
||||
"{error:?}"
|
||||
);
|
||||
let message = format!("{error:?}");
|
||||
assert!(message.contains("Convert the key to modern PKCS#8"));
|
||||
assert!(!message.contains(PASSWORD));
|
||||
assert!(!message.contains("PRIVATE KEY"));
|
||||
if case == "missing" {
|
||||
assert!(message.contains("unavailable"));
|
||||
} else if case.starts_with("timeout") {
|
||||
assert!(message.contains("timed out"));
|
||||
}
|
||||
for key in ["rsa-pkcs8.pem", "rsa-pbes2-sha256.pem"] {
|
||||
let identity = load("rsa-cert.pem", key, Some(PASSWORD)).unwrap();
|
||||
assert_eq!(
|
||||
identity.key_data().unwrap(),
|
||||
fs::read(fixture("rsa-pkcs8.pem")).unwrap()
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// PATH is process-global; isolate executable discovery from parallel tests.
|
||||
for (case, script) in [
|
||||
("missing", None),
|
||||
(
|
||||
"unsupported",
|
||||
Some("#!/bin/sh\nprintf 'unsupported: fixture-password PRIVATE KEY' >&2\nexit 1\n"),
|
||||
),
|
||||
("invalid-output", Some("#!/bin/sh\nprintf 'invalid converted key'\n")),
|
||||
("timeout-wrapper", Some("#!/bin/sh\n/bin/sleep 14\n")),
|
||||
("timeout-exited-wrapper", Some("#!/bin/sh\n/bin/sleep 14 &\nexit 0\n")),
|
||||
] {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
if let Some(script) = script {
|
||||
let executable = directory.path().join("openssl");
|
||||
fs::write(&executable, script).unwrap();
|
||||
fs::set_permissions(executable, fs::Permissions::from_mode(0o700)).unwrap();
|
||||
}
|
||||
let status = std::process::Command::new(std::env::current_exe().unwrap())
|
||||
.args([
|
||||
"--exact",
|
||||
"legacy_pkcs8_converter_failures_are_terminal_and_modern_keys_need_no_executable",
|
||||
"--nocapture",
|
||||
])
|
||||
.env("PATH", directory.path())
|
||||
.env(CHILD, case)
|
||||
.status()
|
||||
.unwrap();
|
||||
assert!(status.success(), "converter case: {case}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_converter_reports_its_password_length_limit_without_requesting_a_retry() {
|
||||
let password = "x".repeat(1024);
|
||||
let encrypted = fs::read(fixture("rsa-pbes1-3des-password-1024.pem")).unwrap();
|
||||
// The previous linked API accepted this boundary. The CLI cannot carry it;
|
||||
// report that limitation rather than calling the correct password wrong.
|
||||
openssl::pkey::PKey::private_key_from_pem_passphrase(&encrypted, password.as_bytes()).unwrap();
|
||||
let error = load("rsa-cert.pem", "rsa-pbes1-3des-password-1024.pem", Some(&password)).unwrap_err();
|
||||
assert!(
|
||||
matches!(
|
||||
error.downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::LegacyKeyConversion(_))
|
||||
),
|
||||
"{error:?}"
|
||||
);
|
||||
assert!(error.to_string().contains("1023-byte"));
|
||||
let accepted = load(
|
||||
"rsa-cert.pem",
|
||||
"rsa-pbes1-3des-password-1023.pem",
|
||||
Some(&"x".repeat(1023)),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
accepted.key_data().unwrap(),
|
||||
fs::read(fixture("rsa-pkcs8.pem")).unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_conversion_keeps_original_files_and_rejects_line_breaks_in_passwords() {
|
||||
let original = fs::read(fixture("rsa-pbes1-3des.pem")).unwrap();
|
||||
for password in [
|
||||
PASSWORD,
|
||||
"incorrect",
|
||||
"password\nsecond line",
|
||||
"password\r",
|
||||
"password\0",
|
||||
] {
|
||||
let result = load("rsa-cert.pem", "rsa-pbes1-3des.pem", Some(password));
|
||||
if password == PASSWORD {
|
||||
result.unwrap();
|
||||
} else if password != "incorrect" {
|
||||
assert!(matches!(
|
||||
result.unwrap_err().downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::LegacyKeyConversion(_))
|
||||
));
|
||||
} else {
|
||||
assert!(matches!(
|
||||
result.unwrap_err().downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::DecryptError("PEM"))
|
||||
));
|
||||
}
|
||||
assert_eq!(fs::read(fixture("rsa-pbes1-3des.pem")).unwrap(), original);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn first_key_selection_controls_password_prompt_and_ignores_later_keys() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let source = directory.path().join("combined.pem");
|
||||
let certificate = fs::read(fixture("rsa-cert.pem")).unwrap();
|
||||
let plain = fs::read(fixture("rsa-pkcs8.pem")).unwrap();
|
||||
let encrypted = fs::read(fixture("rsa-pbes2-sha256.pem")).unwrap();
|
||||
for (first, second, needs_password) in [(&plain, &encrypted, false), (&encrypted, &plain, true)] {
|
||||
let mut combined = certificate.clone();
|
||||
combined.extend(first);
|
||||
combined.extend(second);
|
||||
fs::write(&source, combined).unwrap();
|
||||
if needs_password {
|
||||
let error = ClientIdentity::load(source.to_str().unwrap(), None, None).unwrap_err();
|
||||
assert!(matches!(
|
||||
error.downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::NoPassphrase("PEM"))
|
||||
));
|
||||
}
|
||||
let identity = ClientIdentity::load(
|
||||
source.to_str().unwrap(),
|
||||
None,
|
||||
if needs_password { Some(PASSWORD) } else { None },
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(identity.key_data().unwrap(), plain);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prepared_pem_round_trip_retains_snapshot_and_private_file_lifecycle() {
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use zeroize::Zeroizing;
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let source = directory.path().join("identity.pem");
|
||||
let mut combined = fs::read(fixture("rsa-cert.pem")).unwrap();
|
||||
combined.extend(fs::read(fixture("rsa-pkcs8.pem")).unwrap());
|
||||
fs::write(&source, combined).unwrap();
|
||||
let loaded = ClientIdentity::load(source.to_str().unwrap(), None, None).unwrap();
|
||||
let snapshot = ClientIdentity::from_data(
|
||||
Zeroizing::new(loaded.certificate_data().to_vec()),
|
||||
Some(Zeroizing::new(loaded.key_data().unwrap().to_vec())),
|
||||
Some("unused-pem-password"),
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(&source, b"replaced after authentication").unwrap();
|
||||
drop(loaded);
|
||||
let clone = snapshot.clone();
|
||||
drop(snapshot);
|
||||
assert!(clone.key_password().is_none());
|
||||
let debug = format!("{clone:?}");
|
||||
assert!(debug.contains("<redacted>"));
|
||||
assert!(!debug.contains("PRIVATE KEY"));
|
||||
assert!(!debug.contains("unused-pem-password"));
|
||||
let files = clone.write_files(Some(directory.path())).unwrap();
|
||||
let certificate = PathBuf::from(files.certificate());
|
||||
let key = PathBuf::from(files.key().unwrap());
|
||||
for path in [&certificate, &key] {
|
||||
assert_eq!(fs::metadata(path).unwrap().permissions().mode() & 0o777, 0o600);
|
||||
}
|
||||
assert_eq!(fs::read(&certificate).unwrap(), clone.certificate_data());
|
||||
assert_eq!(fs::read(&key).unwrap(), clone.key_data().unwrap());
|
||||
ClientIdentity::load(files.certificate(), files.key(), None).unwrap();
|
||||
drop(files);
|
||||
assert!(!certificate.exists() && !key.exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn archive_snapshot_and_pfx_preserve_native_import_contract() {
|
||||
use zeroize::Zeroizing;
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let path = directory.path().join("identity.pfx");
|
||||
let data = fs::read(fixture("modern.p12")).unwrap();
|
||||
fs::write(&path, &data).unwrap();
|
||||
let identity = ClientIdentity::load(path.to_str().unwrap(), Some("nonexistent-key"), Some(PASSWORD)).unwrap();
|
||||
fs::remove_file(path).unwrap();
|
||||
let restored = ClientIdentity::from_data(
|
||||
Zeroizing::new(identity.certificate_data().to_vec()),
|
||||
None,
|
||||
identity.key_password(),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(restored.certificate_data(), data);
|
||||
assert_eq!(restored.key_password(), Some(PASSWORD));
|
||||
assert!(restored.key_data().is_none());
|
||||
assert!(!format!("{restored:?}").contains(PASSWORD));
|
||||
let empty = fs::read(fixture("empty-password.p12")).unwrap();
|
||||
// Preserve the native backend's existing empty-password decision.
|
||||
let expected = reqwest::Identity::from_pkcs12_der(&empty, "").is_ok();
|
||||
assert_eq!(
|
||||
ClientIdentity::from_data(Zeroizing::new(empty), None, Some("")).is_ok(),
|
||||
expected
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malformed_certificate_der_and_private_key_der_are_rejected_without_secret_output() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let invalid = directory.path().join("invalid.pem");
|
||||
for (tag, invalid_certificate) in [("CERTIFICATE", true), ("PRIVATE KEY", false)] {
|
||||
let invalid_der = b"secret-invalid-der-material";
|
||||
fs::write(&invalid, pem::encode(&pem::Pem::new(tag, invalid_der))).unwrap();
|
||||
let result = if invalid_certificate {
|
||||
ClientIdentity::load(
|
||||
invalid.to_str().unwrap(),
|
||||
Some(fixture("rsa-pkcs8.pem").to_str().unwrap()),
|
||||
None,
|
||||
)
|
||||
} else {
|
||||
ClientIdentity::load(
|
||||
fixture("rsa-cert.pem").to_str().unwrap(),
|
||||
Some(invalid.to_str().unwrap()),
|
||||
None,
|
||||
)
|
||||
};
|
||||
let error = result.unwrap_err();
|
||||
for message in [error.to_string(), format!("{error:?}")] {
|
||||
assert!(!message.contains("secret-invalid-der-material"));
|
||||
assert!(!message.contains("c2VjcmV0LWludmFsaWQtZGVyLW1hdGVyaWFs"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pbes2_des_remains_supported_without_native_legacy_provider() {
|
||||
let identity = load("rsa-cert.pem", "rsa-pbes2-des.pem", Some(PASSWORD)).unwrap();
|
||||
assert_eq!(
|
||||
identity.key_data().unwrap(),
|
||||
fs::read(fixture("rsa-pkcs8.pem")).unwrap()
|
||||
);
|
||||
for (password, missing) in [(None, true), (Some("incorrect"), false)] {
|
||||
let error = load("rsa-cert.pem", "rsa-pbes2-des.pem", password).unwrap_err();
|
||||
match error.downcast_ref::<RequestIdentityError>() {
|
||||
Some(RequestIdentityError::NoPassphrase("PEM")) => assert!(missing),
|
||||
Some(RequestIdentityError::DecryptError("PEM")) => assert!(!missing),
|
||||
other => panic!("unexpected error {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_unsupported_pbes2_algorithm(oid_der: &[u8]) {
|
||||
let mut encrypted = pem::parse(fs::read(fixture("rsa-pbes2-sha256.pem")).unwrap()).unwrap();
|
||||
let mut der = encrypted.contents().to_vec();
|
||||
let matches: Vec<_> = der
|
||||
.windows(oid_der.len())
|
||||
.enumerate()
|
||||
.filter_map(|(offset, window)| (window == oid_der).then_some(offset))
|
||||
.collect();
|
||||
assert_eq!(
|
||||
matches.len(),
|
||||
1,
|
||||
"the fixture must contain exactly the intended algorithm OID"
|
||||
);
|
||||
// An unknown OID in the same arc preserves ASN.1 structure and algorithm
|
||||
// parameters, isolating algorithm recognition from malformed DER handling.
|
||||
der[matches[0] + oid_der.len() - 1] = 0x7f;
|
||||
encrypted = pem::Pem::new(encrypted.tag(), der);
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let source = directory.path().join("unsupported.pem");
|
||||
fs::write(&source, pem::encode(&encrypted)).unwrap();
|
||||
for password in [None, Some(PASSWORD), Some("incorrect")] {
|
||||
let error = ClientIdentity::load(
|
||||
fixture("rsa-cert.pem").to_str().unwrap(),
|
||||
Some(source.to_str().unwrap()),
|
||||
password,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(matches!(
|
||||
error.downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::UnsupportedEncryption)
|
||||
));
|
||||
let message = error.to_string().to_lowercase();
|
||||
assert!(
|
||||
message.contains("unsupported") && message.contains("encryption"),
|
||||
"{message}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsupported_pbes2_kdf_is_identified_before_password_prompt() {
|
||||
// PBKDF2, 1.2.840.113549.1.5.12.
|
||||
assert_unsupported_pbes2_algorithm(&[0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x05, 0x0c]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsupported_pbes2_cipher_is_identified_before_password_prompt() {
|
||||
// AES256-CBC, 2.16.840.1.101.3.4.1.42.
|
||||
assert_unsupported_pbes2_algorithm(&[0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x01, 0x2a]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsupported_pbes2_prf_is_identified_before_password_prompt() {
|
||||
// HMAC-SHA256, 1.2.840.113549.2.9.
|
||||
assert_unsupported_pbes2_algorithm(&[0x06, 0x08, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x09]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malformed_encrypted_pkcs8_does_not_request_a_password_or_expose_material() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let source = directory.path().join("malformed.pem");
|
||||
fs::write(
|
||||
&source,
|
||||
pem::encode(&pem::Pem::new(
|
||||
"ENCRYPTED PRIVATE KEY",
|
||||
b"secret-malformed-encrypted-key",
|
||||
)),
|
||||
)
|
||||
.unwrap();
|
||||
for password in [None, Some(PASSWORD), Some("incorrect")] {
|
||||
let error = ClientIdentity::load(
|
||||
fixture("rsa-cert.pem").to_str().unwrap(),
|
||||
Some(source.to_str().unwrap()),
|
||||
password,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(!matches!(
|
||||
error.downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::NoPassphrase(_) | RequestIdentityError::DecryptError(_))
|
||||
));
|
||||
for message in [error.to_string(), format!("{error:?}")] {
|
||||
assert!(!message.contains("secret-malformed-encrypted-key"));
|
||||
assert!(!message.contains("c2VjcmV0LW1hbGZvcm1lZC1lbmNyeXB0ZWQta2V5"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mismatched_certificate_key_is_rejected_before_request_client_creation() {
|
||||
let certificate = fs::read(fixture("root.pem")).unwrap();
|
||||
let key = fs::read(fixture("rsa-pkcs8.pem")).unwrap();
|
||||
let error = load("root.pem", "rsa-pkcs8.pem", None).unwrap_err();
|
||||
assert!(
|
||||
error
|
||||
.to_string()
|
||||
.contains("Check that the private key matches the certificate")
|
||||
);
|
||||
let error = ClientIdentity::from_data(certificate.into(), Some(key.into()), None).unwrap_err();
|
||||
assert!(
|
||||
error
|
||||
.to_string()
|
||||
.contains("Check that the private key matches the certificate")
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
# Public client identity fixtures
|
||||
|
||||
These generated keys and certificates are **public test data**, never production
|
||||
credentials. Passwords are `fixture-password`, except `unicode-password.p12`,
|
||||
which uses `pässword-密码`, and the `rsa-pbes1-3des-password-{1023,1024}.pem`
|
||||
fixtures, which use `x` repeated the indicated number of bytes.
|
||||
|
||||
Regenerate intentionally with OpenSSL 3:
|
||||
|
||||
```sh
|
||||
OPENSSL_BIN=/path/to/openssl bash generate.sh
|
||||
```
|
||||
|
||||
Generation is random; it replaces the keys, certificates, and archives together.
|
||||
The test runner reads checked-in files. Legacy standalone conversion tests
|
||||
require an `openssl` executable on PATH (OpenSSL or compatible LibreSSL).
|
||||
No fixture generation is needed to run the tests.
|
||||
|
||||
| Files | Contents |
|
||||
| --- | --- |
|
||||
| `root.pem`, `rsa-cert.pem`, `ec-cert.pem` | Test root and issued RSA-2048 / P-256 client certificates, SHA256 signatures |
|
||||
| `rsa-pkcs8.pem`, `ec-pkcs8.pem` | Plain PKCS#8 keys; expected normalized output |
|
||||
| `rsa-pkcs1.pem`, `ec-sec1.pem` | Same keys in traditional containers |
|
||||
| `{rsa,ec}-traditional-{aes128,aes192,aes256,des3}.pem` | Traditional encrypted PEM with AES-CBC or 3DES-CBC; password `fixture-password` |
|
||||
| `rsa-pbes2-sha1.pem`, `rsa-pbes2-sha256.pem` | Encrypted PKCS#8, AES256-CBC/PBKDF2 with SHA1 or SHA256 PRF |
|
||||
| `rsa-pbes2-aes-{128,192}-cbc-{sha1,sha256}.pem` | AES128/192-CBC with PBKDF2 SHA1/SHA256 |
|
||||
| `rsa-pbes2-des3-{sha1,sha256}.pem` | PBES2 3DES-CBC with PBKDF2 SHA1/SHA256; distinct from the legacy PBE scheme handled by optional conversion |
|
||||
| `rsa-pbes2-des.pem` | PBES2 DES-CBC/PBKDF2-SHA256; Rust processing requires no native legacy provider |
|
||||
| `rsa-pbes2-scrypt.pem` | PBES2 AES256-CBC with scrypt |
|
||||
| `rsa-pbes1-3des-password-{1023,1024}.pem` | Same legacy encryption with passwords at the CLI input boundary; the linked importer accepts 1024 bytes, while the converter reports its 1023-byte limit explicitly |
|
||||
| `rsa-pbes1-3des.pem` | Legacy PKCS#12 SHA1/3DES scheme inside standalone encrypted PKCS#8; optional OpenSSL executable conversion case |
|
||||
| `empty-password.p12` | RSA leaf/key/root with an empty password, preserving native backend acceptance |
|
||||
| `ec-pbes2.pem` | Encrypted EC PKCS#8, AES256-CBC/PBKDF2-SHA256 |
|
||||
| `modern.p12`, `unicode-password.p12` | Leaf/key/root, AES256-CBC/PBKDF2-SHA256, SHA256 MAC; RSA and EC respectively |
|
||||
| `certificate-only.pfx`, `key-only.pfx` | Incomplete PKCS#12 archives: certificate without key, and key without certificate; password `fixture-password` |
|
||||
| `legacy-rc2.p12` | Issue #437 case: RC2-40 certificate bags, SHA1/3DES key bag, SHA1 MAC |
|
||||
|
||||
`tests/client_identity.rs` records native import compatibility and the owned
|
||||
identity lifecycle. `tests/identity_encoding.rs` covers container normalization:
|
||||
DER certificates and keys, RSA PKCS#1, Linux/BSD EC SEC1 and traditional encrypted
|
||||
PEM, first-key selection, malformed encryption headers, and archive extension
|
||||
capitalization. macOS rejects SEC1 and traditional encrypted PEM before password
|
||||
handling. Its native importer also rejects the P-256 PKCS#8 PEM fixture, although
|
||||
its native PKCS#12 import accepts the EC archive. Legacy-provider setup is isolated
|
||||
in a child process on Linux/BSD.
|
||||
|
||||
Standalone PKCS#8 PBE-SHA1-3DES uses optional OpenSSL executable conversion,
|
||||
with missing/wrong passwords preserving the old Linux prompt/retry contract.
|
||||
Other unsupported schemes retain explicit conversion guidance. PBES2 DES/3DES
|
||||
use Rust processing and need no executable. Child-process tests isolate PATH
|
||||
for absent/unsupported/stalled converters, invalid output, and secret-free errors.
|
||||
Timeout coverage includes wrappers whose descendants retain pipes after the
|
||||
wrapper exits or is killed; all pipe I/O shares the process deadline.
|
||||
Linux/BSD additionally compare the result with the former linked OpenSSL importer.
|
||||
|
||||
The tests check archive integrity by changing the UTF-16 friendly name without
|
||||
changing the MAC, and compare normalized PEM output against the independent
|
||||
checked-in plaintext key. Public integration tests cover first-key selection,
|
||||
retained snapshots, private-file permissions and cleanup, `.pfx`, empty-password
|
||||
backend behavior, and chain retention. Unit tests in `utils/request.rs` cover
|
||||
missing keys, large local files, and native request-client construction.
|
||||
Binary file not shown.
@@ -0,0 +1,14 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICMDCCARigAwIBAgIBCjANBgkqhkiG9w0BAQsFADAgMR4wHAYDVQQDDBVHUCBJ
|
||||
ZGVudGl0eSBUZXN0IFJvb3QwHhcNMjYxMDE3MTQxNzM0WhcNMzYxMDE0MTQxNzM0
|
||||
WjAeMRwwGgYDVQQDDBNHUCBJZGVudGl0eSBUZXN0IGVjMFkwEwYHKoZIzj0CAQYI
|
||||
KoZIzj0DAQcDQgAEQm/MjfzelUwWBxNReuqsrrLfBs1ygHeqX6NXBCLWyRWqTI/q
|
||||
BIwba6G3zcnZaArnCw+XsMsBvTtphuiDHouPW6NCMEAwHQYDVR0OBBYEFGySvrUf
|
||||
Wg99yhlvRHe5VcdQV+6sMB8GA1UdIwQYMBaAFNxaJz5kx8+buL1L+wnHUfOmNKDR
|
||||
MA0GCSqGSIb3DQEBCwUAA4IBAQCT4yKBspPRj66lz7y1KjMh0Ju/rVtBlE4pVtbb
|
||||
BYGi29kKVwJyv1GnzKGsbiW7YFEvcBiQFiPV1veab4UR90ESm/SUFXCzwhCkCkQr
|
||||
sYO/tDSyh4vO9zstpN6524lhnEhNqhxrDjwlbHov9Ycsk7nchR2ZXYe7NPF2SZQ3
|
||||
j+NWgOAGHk+xveyfev1sQV8oYn4WL550D0DfCDIVc2n7UdQ2MPw/fvNd1hI6uBUl
|
||||
BrYV+BKeeghn7p7NsesfXqVIuXYbgJ7GFwNh3s3Kdx3p1DQZ37f4P3reSBc7i03+
|
||||
9GmRlPj62a8GnxXFoCcfH4HHp6LkUptZTtHkgyVbsS1Uayj1
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,8 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIH0MF8GCSqGSIb3DQEFDTBSMDEGCSqGSIb3DQEFDDAkBBBP0Qie1d771HAwIaHr
|
||||
16KPAgIIADAMBggqhkiG9w0CCQUAMB0GCWCGSAFlAwQBKgQQJKzM5wh1ay4NLYmy
|
||||
CL43wQSBkLXODq5G55naOF0acp52yJseQ/gpFxKweaqh+dbErhComdC1WW6X1m3x
|
||||
yQZTSGkn9BXXovKbpNPgPbPb7Oks1TEQU33RMi6t89tbZHj757yEY0b+WPpH5Y1g
|
||||
JUE/r2kqpdki7oz5d38R0j7eD1sG/cOvpnkq1jVzp32wRp3cKugLOWx/dC45AhzP
|
||||
X1ZAbDubOg==
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
||||
@@ -0,0 +1,5 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgwiAZclkH//xmntM5
|
||||
q9LIH7sus8oUbh5BnwXHHfRtPNShRANCAARCb8yN/N6VTBYHE1F66qyust8GzXKA
|
||||
d6pfo1cEItbJFapMj+oEjBtrobfNydloCucLD5ewywG9O2mG6IMei49b
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -0,0 +1,5 @@
|
||||
-----BEGIN EC PRIVATE KEY-----
|
||||
MHcCAQEEIMIgGXJZB//8Zp7TOavSyB+7LrPKFG4eQZ8Fxx30bTzUoAoGCCqGSM49
|
||||
AwEHoUQDQgAEQm/MjfzelUwWBxNReuqsrrLfBs1ygHeqX6NXBCLWyRWqTI/qBIwb
|
||||
a6G3zcnZaArnCw+XsMsBvTtphuiDHouPWw==
|
||||
-----END EC PRIVATE KEY-----
|
||||
@@ -0,0 +1,8 @@
|
||||
-----BEGIN EC PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: AES-128-CBC,EDBB75FE8E4A9290FC3447531722071E
|
||||
|
||||
sg0ogRPLzqBeQztwc20ZPqnuQp/2Lv9a1oqY0SLcWm+z0WXVehUSvOVj6vxBCvuX
|
||||
TVzLYA4q6eEIyaCMEzIFLN/A39gmjBhWZK7+amp0orDuFBHoEbAcUJnGpAglj75f
|
||||
lsKGNAfn5p1WEbB2MFFI6WwKgMFDGvKqK1Dw3crQk8s=
|
||||
-----END EC PRIVATE KEY-----
|
||||
@@ -0,0 +1,8 @@
|
||||
-----BEGIN EC PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: AES-192-CBC,DBD38A287B2D983EF72D8314BE8AA5C3
|
||||
|
||||
m/fzWalU1WmEf76dMsUktNG1Jo/Fvd2hKlaGB0/ITNd/tZuVf6pvz4c8+MhJ7dZ5
|
||||
FPVCe/P8crwM9D4beq8TvUq51U2jfy1iejGU9z9lMsXiutpKIOAsG4iSv0FeZALq
|
||||
cCuZ7tpw1LkIZTfRBoFkQmqYN7oZHtwP7+oGbEDNr5E=
|
||||
-----END EC PRIVATE KEY-----
|
||||
@@ -0,0 +1,8 @@
|
||||
-----BEGIN EC PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: AES-256-CBC,5105F89A3448CA69E8C9784A9876D6F8
|
||||
|
||||
FkTcZ+6JtBHQHimcNXHOYiRI8s3n7lMXuss97oBQvqA/duUT2oItEQbQ548uJol2
|
||||
Xqs0uMKY5H0tvZPUoD9zOWCMIlip7Yj0n5eF5sXU+Nx3aGQHWLmroDA84iCagXRy
|
||||
4YGFRiZsgC2GAOGapTcR62jCyIMYgqyJgUyq3JJWtPA=
|
||||
-----END EC PRIVATE KEY-----
|
||||
@@ -0,0 +1,8 @@
|
||||
-----BEGIN EC PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-EDE3-CBC,C4ABB907B69450C1
|
||||
|
||||
4KvcHjy6UN2l0uf5dPwSrEn8eG4aqvUP0wTUazeqmZ0wFYm3BxNX+Ml44SYXk7rC
|
||||
BKWAFGGjE19I+Y8FiwiIUTx3Jq3sV0/zLROPcw2fv3IxtOjWbnJEppOBrgPfg2Zq
|
||||
FxSQq/C6TyARgxb7muzGFiCD5uuuZthlr3yobSu2jJw=
|
||||
-----END EC PRIVATE KEY-----
|
||||
Binary file not shown.
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env bash
|
||||
# Public test identities only. Run with OpenSSL 3; no production credentials.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
openssl_bin=${OPENSSL_BIN:-openssl}
|
||||
scratch=$(mktemp -d)
|
||||
trap 'rm -rf "$scratch"' EXIT
|
||||
|
||||
"$openssl_bin" req -x509 -newkey rsa:2048 -noenc -sha256 -days 3650 \
|
||||
-subj '/CN=GP Identity Test Root' -addext 'basicConstraints=critical,CA:TRUE' \
|
||||
-keyout "$scratch/root.key" -out root.pem
|
||||
"$openssl_bin" genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out rsa-pkcs8.pem
|
||||
"$openssl_bin" genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out ec-pkcs8.pem
|
||||
for algorithm in rsa ec; do
|
||||
"$openssl_bin" req -new -key "$algorithm-pkcs8.pem" -subj "/CN=GP Identity Test $algorithm" \
|
||||
-out "$scratch/$algorithm.csr"
|
||||
"$openssl_bin" x509 -req -in "$scratch/$algorithm.csr" -CA root.pem -CAkey "$scratch/root.key" \
|
||||
-set_serial 10 -days 3650 -sha256 -out "$algorithm-cert.pem"
|
||||
done
|
||||
"$openssl_bin" rsa -in rsa-pkcs8.pem -traditional -out rsa-pkcs1.pem
|
||||
"$openssl_bin" ec -in ec-pkcs8.pem -out ec-sec1.pem
|
||||
for cipher in aes128 aes192 aes256 des3; do
|
||||
"$openssl_bin" rsa -in rsa-pkcs8.pem -traditional -"$cipher" \
|
||||
-passout pass:fixture-password -out "rsa-traditional-$cipher.pem"
|
||||
"$openssl_bin" ec -in ec-pkcs8.pem -"$cipher" \
|
||||
-passout pass:fixture-password -out "ec-traditional-$cipher.pem"
|
||||
done
|
||||
for prf in sha1 sha256; do
|
||||
if [[ "$prf" == sha1 ]]; then
|
||||
prf_name=hmacWithSHA1
|
||||
else
|
||||
prf_name=hmacWithSHA256
|
||||
fi
|
||||
"$openssl_bin" pkcs8 -topk8 -in rsa-pkcs8.pem -v2 aes-256-cbc -v2prf "$prf_name" \
|
||||
-passout pass:fixture-password -out "rsa-pbes2-$prf.pem"
|
||||
done
|
||||
for cipher in aes-128-cbc aes-192-cbc des3; do
|
||||
for prf in sha1 sha256; do
|
||||
if [[ "$prf" == sha1 ]]; then
|
||||
prf_name=hmacWithSHA1
|
||||
else
|
||||
prf_name=hmacWithSHA256
|
||||
fi
|
||||
"$openssl_bin" pkcs8 -topk8 -in rsa-pkcs8.pem -v2 "$cipher" -v2prf "$prf_name" \
|
||||
-passout pass:fixture-password -out "rsa-pbes2-$cipher-$prf.pem"
|
||||
done
|
||||
done
|
||||
"$openssl_bin" pkcs8 -topk8 -in rsa-pkcs8.pem -scrypt -v2 aes-256-cbc \
|
||||
-passout pass:fixture-password -out rsa-pbes2-scrypt.pem
|
||||
"$openssl_bin" pkcs8 -topk8 -in rsa-pkcs8.pem -v1 PBE-SHA1-3DES \
|
||||
-passout pass:fixture-password -out rsa-pbes1-3des.pem
|
||||
for length in 1023 1024; do
|
||||
printf -v password '%*s' "$length" ''
|
||||
password=${password// /x}
|
||||
"$openssl_bin" pkcs8 -topk8 -in rsa-pkcs8.pem -v1 PBE-SHA1-3DES \
|
||||
-passout "pass:$password" -out "rsa-pbes1-3des-password-$length.pem"
|
||||
done
|
||||
"$openssl_bin" pkcs8 -topk8 -in ec-pkcs8.pem -v2 aes-256-cbc \
|
||||
-passout pass:fixture-password -out ec-pbes2.pem
|
||||
"$openssl_bin" pkcs12 -export -inkey rsa-pkcs8.pem -in rsa-cert.pem -certfile root.pem \
|
||||
-name fixture -passout pass:fixture-password -out modern.p12
|
||||
"$openssl_bin" pkcs12 -export -legacy -inkey rsa-pkcs8.pem -in rsa-cert.pem -certfile root.pem \
|
||||
-keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-RC2-40 -macalg SHA1 \
|
||||
-name fixture -passout pass:fixture-password -out legacy-rc2.p12
|
||||
"$openssl_bin" pkcs12 -export -inkey ec-pkcs8.pem -in ec-cert.pem -certfile root.pem \
|
||||
-name fixture -passout 'pass:pässword-密码' -out unicode-password.p12
|
||||
"$openssl_bin" pkcs12 -export -inkey rsa-pkcs8.pem -in rsa-cert.pem -certfile root.pem \
|
||||
-name fixture -passout pass: -out empty-password.p12
|
||||
# DES requires the legacy provider in OpenSSL 3, unlike PBES2 3DES.
|
||||
"$openssl_bin" pkcs8 -provider default -provider legacy -topk8 -in rsa-pkcs8.pem \
|
||||
-v2 des-cbc -v2prf hmacWithSHA256 -passout pass:fixture-password -out rsa-pbes2-des.pem
|
||||
|
||||
# Incomplete identity archives exercise validation before native TLS import.
|
||||
"$openssl_bin" pkcs12 -export -nokeys -in rsa-cert.pem \
|
||||
-name fixture -passout pass:fixture-password -out certificate-only.pfx
|
||||
"$openssl_bin" pkcs12 -export -nocerts -inkey rsa-pkcs8.pem \
|
||||
-name fixture -passout pass:fixture-password -out key-only.pfx
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDADCCAeigAwIBAgIUch4EHQx2jG1SVy93ALCnjWiZz1cwDQYJKoZIhvcNAQEL
|
||||
BQAwIDEeMBwGA1UEAwwVR1AgSWRlbnRpdHkgVGVzdCBSb290MB4XDTI2MTAxNzE0
|
||||
MTczNFoXDTM2MTAxNDE0MTczNFowIDEeMBwGA1UEAwwVR1AgSWRlbnRpdHkgVGVz
|
||||
dCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAorjY7yd+KUlM
|
||||
afkNbdRn8JyJnD/C/blSOcT4qghiGiFrEF3hUvui1bkZSF4CwkyO/d/DVlf5RE57
|
||||
+mSlK/0omDptJifR10NExqNq5pFPYZ+Do7Y75w4NyyPj759ruUTonpm7EFYqQOc8
|
||||
N/QiFfanisQ5D1CO2PwVBe7aKodAgihq6C8SmBKCBRR9m8HDmtckmKnQWNczxOBh
|
||||
7BbAx4WxiQSHxIrt3woSps1QfEHcYTZhPKD7EDRGEMryBvYdI2dtIjVQwRJ4t/r+
|
||||
9sQeK5fJVNYxVjpdtqMJCLT4INBzIKaPKy2R1geWy5a1Zn6EJ1uIx3f6H0NU02Cr
|
||||
Rj5sN3Yw7wIDAQABozIwMDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTcWic+
|
||||
ZMfPm7i9S/sJx1HzpjSg0TANBgkqhkiG9w0BAQsFAAOCAQEAoHAmAMuG4joVReqb
|
||||
81rOQScHfai6lwBVKXsC5lJj/ptfk8n252TObO9s2beOl6mYPs4nMRmq8NIc2ezA
|
||||
CvlndpQhgHhesTIvZGVG43/4Zy3YrzbMSfrYOdlKe6rlIvVbZcMkRIyUbUFVkDO3
|
||||
QjNfOHXMNGCV+2K+/1moru0OkU8fvla1m2b2N6FZIS5q62SVm9HSppqTj/nWS4kD
|
||||
q987vf177vX0qTLWM7YchI+N7IzQyNLElfajJ7SiCBNCz5AggYuwEPmVXdnrdlCe
|
||||
XP7P4t/tZqch0ZpkOvCK2glTNIc+4PHvZ7aNANvaR08QXmSKiwbWX8X9EMdFia7c
|
||||
VvQVDQ==
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,18 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIC/DCCAeSgAwIBAgIBCjANBgkqhkiG9w0BAQsFADAgMR4wHAYDVQQDDBVHUCBJ
|
||||
ZGVudGl0eSBUZXN0IFJvb3QwHhcNMjYxMDE3MTQxNzM0WhcNMzYxMDE0MTQxNzM0
|
||||
WjAfMR0wGwYDVQQDDBRHUCBJZGVudGl0eSBUZXN0IHJzYTCCASIwDQYJKoZIhvcN
|
||||
AQEBBQADggEPADCCAQoC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ez2ttQQisW4GDdx49AVrvJ4QmWb
|
||||
oGxB9viYbgkDbD95vDSqgfUJ9bsIKe8Qn1yx6hR/s+GscS9AtmoajSsUGsO2E2ev
|
||||
05lD6EJmK47M0i/h5WnRVX3oA4CPFN0cNB5F2tNHWTntMw/x5uycWSPzxsp2QTJD
|
||||
VfZKgxxrnP9Gm7pDwYfIOA+LY7AEih0x3qB+YhSiPKwOpae88IziBnsrUJHEpAQh
|
||||
Ve5OtXnZeBcxz/5Ilhg=
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIIFJzBRBgkqhkiG9w0BBQ0wRDAjBgkqhkiG9w0BBQwwFgQQft6DBWIbHgpjlxNy
|
||||
okK36AICCAAwHQYJYIZIAWUDBAECBBA2isANf7/e55ARv/6IU4JpBIIE0CDVlFD1
|
||||
k402g/2yIShzDS3UBeHanmtvUDxfmX0wWVnqBcXKmGFaY8NJGGRXh+1OJFMuxeST
|
||||
VPAePwNOWA0dqEl889KP/3zJE+/YCtwru1P1DETWAXTQNsXCJmUw++SMcrz+FyV9
|
||||
4Ouli5s6CXMDUb7BAcQDjyhMdEqIuvf6CLoUSfBXuy5yUNBOakzL79tGGt5+D5QE
|
||||
C5cdsFSzF8Ft8uOFHh785fdL7tHRJJHZfqdVi6oXLtdqPmoAHXo3YBSClmfBA6q8
|
||||
djXEqSSjyqWcVy6KEpb/dJSmMYXOwbY76M+yK4IdBOkRg2eHLLN22T4YAgMFHIo5
|
||||
S5WP7tNr5RguD2VPOEZKkf44POBdooHweS8fagmLTd9XELafCBaSlIUv5sSTkjuG
|
||||
Ck6g0SCOdkO/qlBur2j/zAoidW9dnsC5TKM4GBNLpnkgo5KQ53AeFbQhcIEo2RM7
|
||||
qMnpKdD3/WJ5vlgsOX36+WpGc0qxkBx7LDlR4PIlpZTAJAl/LjKUAfWjlpnrw4K+
|
||||
tdQ3+C5Ukhms83o0j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
||||
b6br/ec69POUVBPWS6XRx+YvAKz96cGtzb81Aa3aoa3Qu+D6/wWXC7s=
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIIFJzBRBgkqhkiG9w0BBQ0wRDAjBgkqhkiG9w0BBQwwFgQQZ/Awu/UgqU7guQ0o
|
||||
iUbVJQICCAAwHQYJYIZIAWUDBAEWBBCZv8MLB6vhKR9lbtkDUru5BIIE0L0CIxIL
|
||||
G7qAmJ1dK2yUlZ5uH9k58ApCYz/xxFcyB4H6xRgumORe38WOKH76UqO4az8B0X+N
|
||||
tkftkOjG4sXtizKIqT2krJtEBH0SZKleylz8TzdZuVD13/dloEoouhR4vIxjPQcT
|
||||
UeAso21Nobc5o8gTevZutpu8JBmK0mkVc8aKHQVLgR0LXMFsBbcTa8QKgWKhc21w
|
||||
OtxM1XPfvYxHJ6EwPSJBJrt2Ri3bBAUprO4vysmfuCvHgyIhjJKC8AY2ugfOBVmI
|
||||
YotJgbqrxXVEsfEdTHHTdYSN21zpELWlGi1dWBbJiYA5o7pCc7vF4OYOgOO3ci58
|
||||
zLdnMUUYE77qrwM+SfYbKFDxFElbiCxeG2nlmRzqSCmZmEWIZmGiNItqbt5cxrZs
|
||||
Ef4omAPI0uUy2wfey/9moflVS28GY/7NjKFeMuGZ1od+ixml4qGXssYyt8UfvzDb
|
||||
+p6dGvFPBUyAVtmwpPjUU5g9mYrupMUB/BAWhazSL/DDTH/9Zynl0co+/AszTUvN
|
||||
ufHHvcndUA7el42OylMbycZlVla2ZdCVsuNexIfr/9TlFpINqxKmKyWlaYvHXju/
|
||||
T6DCItC/ADvmaa0j6Aw8FPf/ArPPFp9a7N6y93WcCp07Ydm5U07cm82biLF6qida
|
||||
sj7YEj0qUxLXtDSgYzFvywmiB86MpryxnvQXoaZN53gWWeSzZhpRWghBsnWxgIco
|
||||
zenjxiS45nnwRXby4mXpPpNpWVnC0YaTvN1tPvHaM+dAUkxa6BA9xU/uXatofr28
|
||||
zM6YldvNOR99fsuk3zRvPQm0Pj3jszUG48kWXsAgZ/w8AVDiIq0GFm46QDNxm6QL
|
||||
RuTl04MajnskNpj0i6nqs3s8ooBbhYfd+dKUyVAzpLByshewuMniCdVvPGdn8HXP
|
||||
bYbFvMHlD+7sQoFJ4990TwsdCBPjwqbFo1mGbieCL/okncqU7QCOrGWhwFYIy7Wt
|
||||
4VIAwVqkh7tVG56te0C1hJj4V7rWzVNw12Y4/NlkQBWvZlrGCVLelBLF3vX6/R1c
|
||||
OlG+wTuUNswBbnBZzcprjvU4XaeufU0ntsiAgXt4sFTRWwmHZTMf9lHT4GVkVH+3
|
||||
ugMtiL+ePdcWcGYmhPFg1m4atveSoMB0m3vkUJDF/KMDiQaC52FwhXr/G/2wU+GE
|
||||
G6HmnK60AsucXqolZgWjizID/t5DRhIicFfqx8a9Ik6g+qrZoPMzrfIqjsUKIeXN
|
||||
uCvMICHJ+mFy0riFZCOrZMggBregYXdV+mrCpcV18lxCmri+vYXaiY2NaVhcUJOL
|
||||
R/OJiQeWuK4kCQvWnj3YiN9kbUHGfFHH56oeMKbcv+oOha2/ATe7/XlhH3LOYXp9
|
||||
+DOqP+wVlSPQZ7rGCubI+Msc1Zpx/PoyN/VnXDs8A2H5bMUv8+RdAUkzSe3KoMWi
|
||||
KKrB7MbombXrhc7l9dK5vCU5YWAES3c20XzzqZ+SNBUBeFubmfVwdpQXge7sUHAP
|
||||
kh9Yyyc78ruwZrPE4x0d0mQmdYbWK6fqAO0VWuF6YrRfGaPBUFbHEXCVk5YBc4+O
|
||||
biLmxV/POGF6L0VLlaXnkpMk6qIUpILmoS5FQaz8KLetlAPd5pQuhkOmnaBYGeTE
|
||||
d78fn68IHzmRw/wdyd7/f3I/74vO0HcFFy01
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||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QC+fplqwrBYxBgfA1txnCa20twESLaNHqLqfe26t9vErNxssx
|
||||
UDIw/El+3rBJlDjrjnbDQ+jwbAtcXQFhwNLMvnB+eLF7ALylrfU1H8+TvptbghfV
|
||||
1GQgidw9rJ7UvQGkcPOsa0vDMnnzSev0xJf1d0t3YlRMGP7N2RRO3SqjeYET4pzh
|
||||
TsOrVjYMA7se8vmyf64nNk/4w6pOsmW3SEO+fro3dH4J0MwP8d/+swdLpZlESVME
|
||||
fLLMRwOxR5Pzr30v8sSl77tVm99g3gdXiZHmo24E2vK9MjSvHBs6LEwX7NezAD15
|
||||
ZzeKRe8FeaigJTu68UNbIFMGXds0A4pP5DOYTkY1T0/LdUT/kC0hS/h4rfi6ebjZ
|
||||
fQEH4Z7Fax5khP089fUs8HLpAuNBlcDEl1gY/QUcQ+ZPQ2ybnv0xiH3AO1Gfe7iA
|
||||
W1x+Btu2Y/KBIewtt6WfC7tfU6Ymau2xhb+YeWOchHGdx9+TJvmlfSeGbfazaFUT
|
||||
v6WJBmeMRPYLglFiPtOBtv+a1sa/CRtI5aeQu/Vt7/NpgUt+bmdFhSb1BaLVDMnd
|
||||
XV+e47lpg/rrmGwEIpNKutxo2LTeRGyO5p68362S3t9XpJVEbo6pUT1H/e9I4tqq
|
||||
bMnI+Y158sbEOXHrjAtPR/qyHt84g2HPWd9kBzofYfsH23crbCP88a61EuSSSDeW
|
||||
WZiV+4CyLZiFAdPtHjGotcNCy2SKSQVbtTleOssDz7k2LVLingCg1zy/smzv6vQ3
|
||||
WwsDQwfvlNelsrs/5C9t8V3/TAKKuZOQqQk6QHJQ6MJpnPicNlZpKjc=
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIIFITBTBgkqhkiG9w0BBQ0wRjAxBgkqhkiG9w0BBQwwJAQQL3LfHM5IdiCRo6Jd
|
||||
on16lgICCAAwDAYIKoZIhvcNAgkFADARB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KmN9+jG58MRnLL568aQTyIvrePJK25P28
|
||||
xbpSb+widMmFYSDrxjzxl2iUcdTdR7pUX/qldO2oOngXA8FfDxhNuOJtidoPMGBF
|
||||
ygypYHxIMrhmEV42tXODE5uBi1KWtJ8xEGhcJqvsOrWWf7cv//aPTmdSv/kcazCk
|
||||
ReNlVLk3vUAjA18OiW83unQjWt0J0jJ0F5jQTm7WfW9VB7L55qe9ExexNFl5CPJc
|
||||
JYNWSBvg6MlEzvk+rD/hDOszFdrLS5A3HtJIY9+3qO+OlqFtlp9JIaXmfke2dMy1
|
||||
PHHLD1PgYZ5vyBIJbf00QKclsVG5vrLYvDTv9kNKZJhVxbagzax1b6WGY6GIrR9N
|
||||
8dRQpkCCYqUYgzanpkLQfofxb+TTv6JSQIRZSHKpxR7wQBuS7lT+6fTRE1tPB4OU
|
||||
JPXn3W1jx05K/OxeyCFtpN/xLnnQKvnj4ZU6DXB9vO3UydUtCSpq9KvDvm55lll4
|
||||
ZkuGey11V+pn23s3ygVFuV4oPvg9zk5wHUQAlWkUL818T9pIwFLN+H10rNSVitB+
|
||||
YxlgGQfLhKsjyuUyTpKUwhqp6idosFkioWB5lmLoP5Brdsm7eOYe/sLEbUKxbEFD
|
||||
xKKA7XVaqJQEPb8+069Q9iTlxv00Zng4plMNtKh2r9j9h1VOEQzLaV33yS6Wmuw6
|
||||
XJXa4mML2vuEWv8kpnetqCG/8aFu
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIIFFjBIBgkqhkiG9w0BBQ0wOzAjBgkqhkiG9w0BBQwwFgQQr23WBmE1lkxsGA1t
|
||||
yZ+WjAICCAAwFAYIKoZIhvcNAwcECDNnS5hARTEYBIIEyI/XTneU4bZPrEbXBVuY
|
||||
eunGKPNfmUJAfTftRO8w7K5j0zXo01Q9POdPbuNvVPsQQhv10Lq3hAjOeoMbWIGR
|
||||
NW2a8/Ru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LHn/dArxT4Oz47lingsT3TW6E15gCqSEKbHsV
|
||||
qGtlCoj3zFzmVW7y4UFXrOz93BBmaR1nI3nwLokSoxPMD+hoXjlsexpCrOKdWHQ+
|
||||
RaRmpiLRwGwH+ukrRwIfPCwS7+an4lUxOmFM327zvcJiVaLMLk0oHVFgl8wRUKWN
|
||||
7Cn9KIKtt/1M2v1k94EV+sr2zO2SRO4659rKJ2WHT5HeBhbaAe08Oz9EW9aealKL
|
||||
kMEE5S9bqHVu9amz2RuJ92V8Fjs3bTBYSV/spl85VAH0Q7pMUKRHALuUe/sBI2A2
|
||||
miyum1F6WSslnxEC88PGFzbF87qZEkntF+nJheP2GnqUV4XDCvvvNfGkt40NGcv8
|
||||
v/rnVBJFGpgOLd4S2BxBaaKM9HhM9qtiHrTeo536FAENDfkNO1IDeytLqMZlK0os
|
||||
eHRLfG0NMKpMMMndyJ1BuvJHOIu5Ph3LcP2ghuVVnbvDO0thqblGCXWsjOEfuhFF
|
||||
cIUFlGyWVyh9RsFmqZgGJ/ACJ2yr/ENgATWPNEMhHWUp07hUphNFGk+0p+SWrCsW
|
||||
+caljkPly+7J0A==
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIIFJDBWBgkqhkiG9w0BBQ0wSTAxBgkqhkiG9w0BBQwwJAQQPrSU6A8HS2rfL2Aw
|
||||
tj4NAgICCAAwDAYIKoZIhvcNAgkFADAUBggqhkiG9w0DBwQIlos2bamhisgEggTI
|
||||
DrQM/Syozmo0P0VjQYYB1LHUw/LRP/m+/7vJSDtg9gsxmFlhe7fOFc9nBV2Lk1aT
|
||||
QcvADQm3vzmQxWllXIcqHUAbnt9YmMCxOX5rgfxNC2OIRwsxKENcIxASUrurDNd2
|
||||
YfSyEYKdqNGbgpCOFQZN279Fak1IaGaWWfnhvVV1tfrtmNKd4DuW/JB5BVLKeZXC
|
||||
xZJ9KyocmciAROX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fdh+hWn0N47TTMChBI8P9WBHeKlo3+soTxhW08Fztk5Ypp
|
||||
80zlgAEQLsqCCkZLnUys0B3vSu2ipcp1RWI7fFdNzr7qXdfpraF6kpPkI6vsGuS4
|
||||
8DnB13vjfGm22DM0gyahrgWbEYbh0qjdPU9YNFkAdw22QZZM7DRxgexABo2cBJ4b
|
||||
DsZyR6X9mAUF+GoM9uk6LlNHOBjJhf1hQghUFafzXAnv2uRWTKElX8495BQIMkJf
|
||||
7wWvD0xFouyOaBs2WG2sVvqLEsuaDWma5hl8OHfIBy/bGtM7kTTPpyW7GJhl7UpS
|
||||
ECr2FeCU+AxE4d1fLLSk0NJ3p6D15BUD4J3jZsCXUKWV
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIIFJzBRBgkqhkiG9w0BBQ0wRDAjBgkqhkiG9w0BBQwwFgQQaWRBwIFvqszAZR3q
|
||||
Ela+lwICCAAwHQYJYIZIAWUDBAEqBBAhUTeex/AihIZOOCw+Di7xBIIE0O2QU8kp
|
||||
fBGNyBtIJNFfeWw14v3nTRYO2YUjOCTYc86xPNJK4yV69+lxuQ1ibGQim6QSaGU0
|
||||
xoooQh1UoTHNpp9hEF+7dcvGJkOzTg5UqshrNL9d+x5CbIyfiMO23pa69VnBWeRo
|
||||
4TwICc7MMT95FUkbONjbIg0jqtaCsmIEIvIIfj/jk87yAGfAqfY/5IbenXP3526M
|
||||
xzMGDn5ysPYsIVNN672uRoRLL8XlR6oFVqA2Gljg38+jq5vfj7dQeRuWk0Np27Uu
|
||||
dbv01SJctGIr+oLcD6gN+WQLhxgudJxy7jkmYBB6Gt669Wqnevv0konv6fk6w9hJ
|
||||
Y7/220hSbLxuD0Qki34zJQ9Illi0OmsAuw575/2aEHozaJkvUPsXfbiCDiO6ykQm
|
||||
HPjAMKmOIC07Uz/4VYF4EiBW94VE46kjfsXeSratSNcrZjl3qcEyQ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QJr9X0GxzPmeml4BwF+zR34DyoF47t9oNqZ+D+ZZZ+85KFN5qpWxQ+78aON
|
||||
kmLJS2aDLFbbixAinSWtC7T2WlrunRKtqhHbD16OlSwaqSbCTK/BXvAcyjQOCRWU
|
||||
V6gskJ6Dup1pFscy63jW4H0nreH4hLignVAafxpo7HGJU3/UI+HsWrgNxL5yusoe
|
||||
+MTlZRDeoBLKnH9aXKW887SVzPcZIJw82QOo
|
||||
-----END ENCRYPTED PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN ENCRYPTED PRIVATE KEY-----
|
||||
MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQKNgPQnRyv9a3bJxh
|
||||
F/mvLwICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEHm8bkHGT8F6igjH
|
||||
EjG0tWoEggTQSV1Rw99vpqwXzU9twY9QPlk/OX9znHaHJhjURg6MocfiRPRVY73l
|
||||
pALAqX88fwD0opmYPcVn1FgN5I/xg7hHu7nXXeddAGnEvO4z3uP2pJXeankjwPwB
|
||||
upJRXIpRScenybVA9t+OQj9RQW+Wm0l7/yArgiiV5h8lprQWIQEYOVqnFsQ+wrQB
|
||||
jHaoH5sJmrOuRKDqQRJqvmANzbNrWDCTcAoTf9tB4lZqJ/7/SLQBeh39AiepXcMt
|
||||
JzCOPbn02UJ0DhHT+PZS6ZAyADYDNfgSxY8oh6oK3DO1JS5uzVLHyWx89uXJk7eX
|
||||
qWX5y91Qv5simVN6Eyhtb7Zxwc6Q2ux+6J1WrTIDV9F9KyZINvcQyeYn0QAhOh8w
|
||||
D46jpKSS7WplW4hzYC4YBSldPlFlc1DEDlyPP4rRP4ngyFS10fVH8SGblWFBSq9T
|
||||
f5mA21b5Mww7T4MEuhXNl9DIIJGmm+MvzYin3OGUVXxpScPtzUjaZxFXMzNoxnuL
|
||||
sRHlAD9O+zAqmLK9DMF1iohoZ1tcxSueNE4YkeTovZNFuZ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2je4eQxFCTxuKveWHiOQh0tnRtnzGaRqv4QDUm0XFCLXwdPhDp
|
||||
bXo4KuEVqRICOLJEe9GIOJO0xvzcwTv2A1YzTnu1G1pg7GaeiG4Si3cCgYEA5Lpr
|
||||
7goqHEJEUm6MTowkXzuahXRv0lOAkZkb16hjzUW4RJuKNHvyibaqBVTQ6b7iRLNK
|
||||
omyXLUMamShYB353IKMWldAT4D4TNBirblJYN/z2h2nf05ZdQGGHAuTTmz3HsYhT
|
||||
twDNLJqhb3cGQAX/lLPXQx74HdjGyvQjmhf1sXECgYEAmL3U8xtpXWopyH8jfcbW
|
||||
+yGhja4Vb/K4q7OfN59ea6/DHowk9CJyviZfetkXULYa/9RnJNHLr9pab1p51VTw
|
||||
lWGsW6rY3bzoSl31hZqtXOAudEkMvGgvEtjDwS1j4/VeRH73Pq0y/otwBZL+RCqd
|
||||
OIRJYBke28sIIacoFIqTAhUCgYEAzzAC9lQkwwZP5y+WTsxpYg6WsQ7BAA99peXA
|
||||
L8Cr7tSZzyPptBMWpyJcrome2C19vud90tV0t55SaKv/2YH4HQs+OSSL7JOuR4GV
|
||||
QFC88rJlClKgWoSZIel2J+vptnTm/+zSkDHcqOvFEjgJ5FLKqgOiGX3jGP41TMCL
|
||||
w1iyyTECgYBJCzaBLXXPDPMWNK/5aTo0GRuO714kiwehvp1K+sSRKz85qx4r8Cb/
|
||||
anDVf8ONZR5mIzKUgEO3HppTKgG+yfgQg2cTsNZXuWwOl8FV83I7Zno7HMm5Rem+
|
||||
NyHj0Yb+k3D4TyB2AVE4YD78u5jXFIWrJVroIAO7mRXwD/gkZWphcA==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDd1Qd/iKhTpVWO
|
||||
jhfwPTqlaj9Ac6CKubFr0fZsVgR8r1OSmRv16e2tjhfjjhOI0cz3S4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/WxcQKBgQCYvdTzG2ldainIfyN9xtb7IaGNrhVv8rirs583n15rr8MejCT0
|
||||
InK+Jl962RdQthr/1Gck0cuv2lpvWnnVVPCVYaxbqtjdvOhKXfWFmq1c4C50SQy8
|
||||
aC8S2MPBLWPj9V5Efvc+rTL+i3AFkv5EKp04hElgGR7bywghpygUipMCFQKBgQDP
|
||||
MAL2VCTDBk/nL5ZOzGliDpaxDsEAD32l5cAvwKvu1JnPI+m0ExanIlyuiZ7YLX2+
|
||||
533S1XS3nlJoq//ZgfgdCz45JIvsk65HgZVAULzysmUKUqBahJkh6XYn6+m2dOb/
|
||||
7NKQMdyo68USOAnkUsqqA6IZfeMY/jVMwIvDWLLJMQKBgEkLNoEtdc8M8xY0r/lp
|
||||
OjQZG47vXiSLB6G+nUr6xJErPzmrHivwJv9qcNV/w41lHmYjMpSAQ7cemlMqAb7J
|
||||
+BCDZxOw1le5bA6XwVXzcjtmejscyblF6b43IePRhv6TcPhPIHYBUThgPvy7mNcU
|
||||
haslWuggA7uZFfAP+CRlamFw
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: AES-128-CBC,1DA771DCC527783F6EFD4C6CD926AB1D
|
||||
|
||||
jBGtgZupvnF4w3Abxswu06uk/GZt8fe6HJ8LqwqhiO4grseWfTgUFD/UoQzuAO8U
|
||||
YrtKDbf1A/Ps0oe6pUeHUwIyw5nUU3gryFTmip5cqVuEOZJNdxCTV6Vyc5j4DQzc
|
||||
cGOOBLR6bgi0l/lc2B6dHIlWYv/elnK7oYHbEOVehX8w4hQzLG00fDQmxyEQqBBA
|
||||
HwZWfTLCEYHMdKf0RelPYk5OwbUq7ePn4EqNXHddmEvZNK0LVOfD9KFO/4Yy6DIa
|
||||
5kLfOG/E3J82ldvwn1AYVKKCPjdKNl45u52wfgL/GbDxv29p/Z2HqEGhs5iA4weK
|
||||
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aQOLtM1qcKthf0NyVxQKcO7KYe7HDIaVjUsUr9Oz+UG2Qwxi
|
||||
yiB5XsjbU9dFn8X57HMqvZOW8kICnucqurFx3RruO1CrWG0OlRytP8BjtI+sCLnl
|
||||
Y7OYuRHLJClJZMgVCJfWNC7wjvX39gY1PjbYVzNwGhnOFu12jXFE7+s0KT2G575M
|
||||
XQE8OZ208P1rlDo0PHvs2tlk1bOz942m14tpABzXkEIC35OHjwj6Vi+aGrU4kv2i
|
||||
HhVTsSwPDrCf5acTlmawxKoj2jAey8xHRlrV6O7B94mEJFCEbHjw7thVd3ssoSLT
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: AES-192-CBC,3676585752281E1F13CD59E6EB36EC8C
|
||||
|
||||
ImHFk1Pvr7eeFtS7eorBiq1eMNEJqn7ydhMOsP+4GCJ42zihMSbkwIbEt5Q7h3oO
|
||||
G0aZvr0vwnYIvWWwc9s7jdpbKU4w6ll00xDL2bmbFGoyJx9li8fiYL7SrHg1Uw6A
|
||||
0VFKuBCBjndQaRAw1+YFETscIcw2g3qdeaO2C4DKLQqCE/INucGCAljzjcevRNIo
|
||||
lxM27bQQgO2iI99LVAeXwPFgGij0QBJnI50Fydsv+b65Pn5AVl8Q842Qjb6OuKs5
|
||||
UinlPMSzvZ824FO8Q4eGHyVVII2o9RGQRm249szyxwm/a5TetGzMQaZo3vERYTtL
|
||||
fR65j0YiCuqfCb8seKywtvcUITRo2Da5bS+ZvxUxuP01JyEd+0N/h/ekUyBBg1q5
|
||||
pb91zrdI4aL2he1m6EQYqzxka6UZWrKiKaw5UEVb9cC2fftxaInRa8h/WDqCN8U4
|
||||
ukVg2SLDMT+6BWTeEVSFOY6727Dy9a9UBneHc1ejvX0lrUmsL0w42tH2AI+WZx0c
|
||||
saRp7ali+/Gj5E7otchakMAfjusZ0pNCcuRHaPY6Q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||
KeDM8dvtKu8bb6NRYOAmg8icIzTbcGhnFHZbiFfaqBX8Qd3yWk10KmdJipU3Rn+t
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: AES-256-CBC,C47A164F22721903963FC768F2BFF0FD
|
||||
|
||||
Ultu7rEweaaOx6V8pce+mVsFmaDSOGyZjBk9eUOIcdIEseDmzms4TBNyYBddUrhb
|
||||
6AiIwo1kz/2D7YED7dEckyuZyX9LETDcno3MwwDrXAve0Nn7zj4qgHl+Pj2GBfWf
|
||||
PioDdmXHthbOjJp5rHgR9+gYbhPYnBW09OV6ml1WnPjqOlpsI1izKa3sWBsje0/W
|
||||
rNiHM4AZ2TJbrI9/rb9Nvd3X4t0RdsKsHpocxuBzq9YOKTt/rxD3uwI3fBkwyySZ
|
||||
PZhWxBL1iydiMwTWpXd6RwpH20pjUWyxzBdeb03py8ZE6kW8nA/GT5pu+wKnWoLk
|
||||
c/I1S0tKcI/LjRrOtorBNyHy2+sVH4vQVHCiCA6JV0+7u+uNP2SekQ/+8OsXB6bk
|
||||
KRslQeuIrEhqdUmwkrdxP5fu6034/pPFdBHo4qbIYRY+vCvzJYuRLQfyapzSacNo
|
||||
qloRG/aMxJtg1SZdQnE/Zt7bj1tow3b/Ks4fmX/xdO12Ye9GrEbEXu3yXGky7yz8
|
||||
z/n9eUYvhUP2qvVxqvHEZlEnyixTRRC5YO8PovpWAM7XdhbdVculfgqYm8JQaqcy
|
||||
DBkT5t6AExvRpTXqkIAG+RMlsUHCoFVMJJyGK7eMtg94RP+Y97bAaAlch4Cw/ulH
|
||||
9m56MluMtbThKRy4gxIojNb/Vd9poAMmNJVlB5gY5UGrbeLWxvVZzFDcv5BmadIa
|
||||
iJyJ/TrLvHhH9umewBqGYafnNJNdlp2PbZ0eRx7idCwlhOwhhuBJZTqLNoKK+CYt
|
||||
6GrG04IZQB+N2id9hXTNyomaASBXgc3Nq+CnLssIpPLfHB0O4f7boYwlPCzsIrWE
|
||||
EAeGBOZv3Njv9iuKX9HhB8GDNcQ4TSJ1ShsnqULDpbklza+fL8HEmD00BKY4AuIO
|
||||
RmH5CgmHgW0MwBuX2kJDd7Hrz9WJB6vKNOLuNsai5xX9L+Ivsk+RB+YQLoMSBk24
|
||||
DpD+LRgKTdY/vakinHpR9inznUjBQbg0KZtmqxlcznlVmo5Gx3imWmCNurmW+wwQ
|
||||
kn4mj0gI99VMWbWwJu1mUVt2j3Zy1PgeYbCtG26VfOW7a+jl7+a31LIn9taQzFH2
|
||||
20788uRl96kx3ijETCt/VGuqj+tZx8bcCz4o+22K2ycqzYlStKq17PCm2yrWYbXD
|
||||
nWEdXpASv+blugFDH/GvBSf5RGP0HYbSIIVxcruvJerlIkc9tWb5+gs/beEzV/Xu
|
||||
c3BYz5fpljecprZJq8TvBvb5T8mK1D3YdZnp7COWxY+I7wt9PP5GTqOzYFmauFZO
|
||||
/AOx0VickKMhfLLC4LkLGfYnaRpMpQ9pB3Z8AhLsY3mxXBxKYacIT6dgUXafpRKO
|
||||
13ILxvG+VC6Q9yScm6GpL8gsldxDQXzQ6STyDjw5wR42MqtqA4tTmnkxSlsPdj9i
|
||||
R4WeUjAtUXj/VBfB9X85LVjpN+thHpZwYtpvYdWk4CAqVAl8pjHkndm4oWpKxMXC
|
||||
OeQpZVsd/t5ZKGDwccKrUm10nQmeDw4NNzQDsLWCB15E60cegsGcBa27BVwYhVnf
|
||||
25iyJp525Sio9LFJDNk3UNSof2n2TrbF9EyhRIZhx2guIxKomntoAuT1NcxiDEUz
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -0,0 +1,30 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
Proc-Type: 4,ENCRYPTED
|
||||
DEK-Info: DES-EDE3-CBC,083D46DC0D0EFB2C
|
||||
|
||||
iJLYLqu75j6reCA0CvZLBN7SpZzJufa3emjV+vl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QxryQI
|
||||
wUpx7c+c8aZqkbqAp9/2KPCuiGfgiq7RJgtFHlFaHIG9q6ulKv8Oo+ULA/eLTaP4
|
||||
rwUNzF6fFKXwnfwbPj2LxbHYQ18q0pWJpvTR+7/a8osCipwb+MZTzQ33ckghjeQG
|
||||
+zCa1rRRvha7oe641WTq9hbKUnBJa385/7xkhGfCTuhRsqOui83UAnC+GXdKsJaS
|
||||
pfstw1zVlKMHetW0WRaboQu5LHMCdYYOOUJSRSzJN0+r3m9PrfA9y7UR9usrhYUZ
|
||||
s4bY0louuzyZ6u7N67v0hVFvgVHEyuWavXHHRzlau3jrcqD57Fpp9zZP+TDEf7aW
|
||||
VKTJYsbdVhbpQnQhRcSUHC78NqVp1dXf85i6Fr/dLBuG68VcR3pvK7xxTPsrv7Bd
|
||||
a9c9ORbF+wgMJc0LwjFo5N27c1NfnWCJXf4rPUhjtnpcF3Vs5p/0rKWxdYDHC4gi
|
||||
KobPxDZgVdFpPzfXHGvNzz6pX1o3okKtD76f6apFI/uKn14MhFRAspWMoX39YPkv
|
||||
kzklzSVOziWQ+c5lO9JWofs18y3Yawdu9SPoyrQOFfQV7aCTgX54E2qNmS9gksLd
|
||||
-----END RSA PRIVATE KEY-----
|
||||
Binary file not shown.
@@ -0,0 +1,274 @@
|
||||
//! Container compatibility through the public identity loader, using public fixtures.
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use gpapi::utils::request::{ClientIdentity, RequestIdentityError};
|
||||
|
||||
const PASSWORD: &str = "fixture-password";
|
||||
|
||||
fn fixture(name: &str) -> PathBuf {
|
||||
Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("tests/files/client-identity")
|
||||
.join(name)
|
||||
}
|
||||
|
||||
fn bytes(name: &str) -> Vec<u8> {
|
||||
fs::read(fixture(name)).unwrap()
|
||||
}
|
||||
|
||||
fn load(certificate: &Path, key: &Path, password: Option<&str>) -> anyhow::Result<ClientIdentity> {
|
||||
ClientIdentity::load(certificate.to_str().unwrap(), Some(key.to_str().unwrap()), password)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn der_certificates_and_rsa_keys_normalize_to_the_existing_pem_identity() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let certificate = directory.path().join("client.cer");
|
||||
let key = directory.path().join("client.key");
|
||||
fs::write(&certificate, pem::parse(bytes("rsa-cert.pem")).unwrap().contents()).unwrap();
|
||||
let missing = ClientIdentity::load(certificate.to_str().unwrap(), None, None).unwrap_err();
|
||||
assert!(matches!(
|
||||
missing.downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::NoKey)
|
||||
));
|
||||
for name in ["rsa-pkcs8.pem", "rsa-pkcs1.pem", "rsa-pbes2-sha256.pem"] {
|
||||
fs::write(&key, pem::parse(bytes(name)).unwrap().contents()).unwrap();
|
||||
let identity = load(&certificate, &key, Some(PASSWORD)).unwrap_or_else(|error| panic!("{name}: {error}"));
|
||||
assert_eq!(identity.certificate_data(), bytes("rsa-cert.pem"));
|
||||
assert_eq!(identity.key_data().unwrap(), bytes("rsa-pkcs8.pem"));
|
||||
assert!(identity.key_password().is_none());
|
||||
let snapshot = ClientIdentity::from_data(
|
||||
zeroize::Zeroizing::new(identity.certificate_data().to_vec()),
|
||||
Some(zeroize::Zeroizing::new(identity.key_data().unwrap().to_vec())),
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(snapshot.key_data(), identity.key_data());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn encrypted_der_preserves_password_errors() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let key = directory.path().join("key.der");
|
||||
fs::write(&key, pem::parse(bytes("rsa-pbes2-sha256.pem")).unwrap().contents()).unwrap();
|
||||
for (password, missing) in [(None, true), (Some("incorrect"), false)] {
|
||||
let error = load(&fixture("rsa-cert.pem"), &key, password).unwrap_err();
|
||||
match error.downcast_ref::<RequestIdentityError>() {
|
||||
Some(RequestIdentityError::NoPassphrase("PEM")) => assert!(missing),
|
||||
Some(RequestIdentityError::DecryptError("PEM")) => assert!(!missing),
|
||||
other => panic!("unexpected DER password error: {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ec_sec1_normalizes_on_linux_and_bsd_and_is_terminal_on_macos() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let key = directory.path().join("ec.der");
|
||||
fs::write(&key, pem::parse(bytes("ec-sec1.pem")).unwrap().contents()).unwrap();
|
||||
for source in [fixture("ec-sec1.pem"), key] {
|
||||
for password in [None, Some(PASSWORD)] {
|
||||
let result = load(&fixture("ec-cert.pem"), &source, password);
|
||||
if cfg!(target_os = "macos") {
|
||||
assert!(matches!(
|
||||
result.unwrap_err().downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::UnsupportedKeyFormat)
|
||||
));
|
||||
} else {
|
||||
assert_eq!(result.unwrap().key_data().unwrap(), bytes("ec-pkcs8.pem"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn traditional_encrypted_pem_has_platform_specific_support_and_password_errors() {
|
||||
for algorithm in ["rsa", "ec"] {
|
||||
for cipher in ["aes128", "aes192", "aes256", "des3"] {
|
||||
let certificate = fixture(&format!("{algorithm}-cert.pem"));
|
||||
let key = fixture(&format!("{algorithm}-traditional-{cipher}.pem"));
|
||||
for password in [None, Some("incorrect"), Some(PASSWORD)] {
|
||||
let result = load(&certificate, &key, password);
|
||||
if cfg!(target_os = "macos") {
|
||||
assert!(matches!(
|
||||
result.unwrap_err().downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::UnsupportedEncryption)
|
||||
));
|
||||
} else if password == Some(PASSWORD) {
|
||||
let identity = result.unwrap_or_else(|error| panic!("{key:?}: {error}"));
|
||||
assert_eq!(identity.key_data().unwrap(), bytes(&format!("{algorithm}-pkcs8.pem")));
|
||||
assert!(identity.key_password().is_none());
|
||||
} else {
|
||||
let error = result.unwrap_err();
|
||||
match error.downcast_ref::<RequestIdentityError>() {
|
||||
Some(RequestIdentityError::NoPassphrase("PEM")) => assert!(password.is_none()),
|
||||
Some(RequestIdentityError::DecryptError("PEM")) => assert!(password.is_some()),
|
||||
other => panic!("{key:?}: unexpected password error {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fn traditional_passphrase_with_nul_returns_a_redacted_terminal_error() {
|
||||
let error = load(
|
||||
&fixture("rsa-cert.pem"),
|
||||
&fixture("rsa-traditional-aes256.pem"),
|
||||
Some("secret-password\0do-not-log"),
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(!matches!(
|
||||
error.downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::NoPassphrase(_) | RequestIdentityError::DecryptError(_))
|
||||
));
|
||||
for diagnostic in [error.to_string(), format!("{error:?}")] {
|
||||
assert!(!diagnostic.contains("secret-password"));
|
||||
assert!(!diagnostic.contains("do-not-log"));
|
||||
assert!(!diagnostic.contains("115, 101, 99, 114, 101, 116"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn first_traditional_encrypted_key_controls_combined_pem_loading() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let source = directory.path().join("combined.pem");
|
||||
let mut chain = bytes("rsa-cert.pem");
|
||||
chain.extend(bytes("root.pem"));
|
||||
let mut combined = chain.clone();
|
||||
combined.extend(bytes("rsa-traditional-aes256.pem"));
|
||||
combined.extend(bytes("rsa-pkcs8.pem"));
|
||||
fs::write(&source, &combined).unwrap();
|
||||
for password in [None, Some(PASSWORD)] {
|
||||
let result = ClientIdentity::load(source.to_str().unwrap(), None, password);
|
||||
if cfg!(target_os = "macos") {
|
||||
assert!(matches!(
|
||||
result.unwrap_err().downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::UnsupportedEncryption)
|
||||
));
|
||||
} else if password.is_none() {
|
||||
assert!(matches!(
|
||||
result.unwrap_err().downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::NoPassphrase("PEM"))
|
||||
));
|
||||
} else {
|
||||
let identity = result.unwrap();
|
||||
assert_eq!(identity.certificate_data(), chain);
|
||||
assert_eq!(identity.key_data().unwrap(), bytes("rsa-pkcs8.pem"));
|
||||
}
|
||||
}
|
||||
assert_eq!(fs::read(source).unwrap(), combined);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malformed_traditional_headers_are_terminal_and_do_not_expose_material() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let key = directory.path().join("invalid.pem");
|
||||
for (headers, unsupported) in [
|
||||
(vec![("Proc-Type", "4,ENCRYPTED")], false),
|
||||
(
|
||||
vec![("DEK-Info", "AES-256-CBC,00000000000000000000000000000000")],
|
||||
false,
|
||||
),
|
||||
(
|
||||
vec![
|
||||
("Proc-Type", "4,ENCRYPTED"),
|
||||
("DEK-Info", "AES-256-CBC,invalid-secret-iv"),
|
||||
],
|
||||
false,
|
||||
),
|
||||
(
|
||||
vec![("Proc-Type", "4,ENCRYPTED"), ("DEK-Info", "AES-256-CBC,00")],
|
||||
false,
|
||||
),
|
||||
(
|
||||
vec![
|
||||
("Proc-Type", "4,ENCRYPTED"),
|
||||
("Proc-Type", "4,ENCRYPTED"),
|
||||
("DEK-Info", "AES-256-CBC,00000000000000000000000000000000"),
|
||||
],
|
||||
false,
|
||||
),
|
||||
(
|
||||
vec![
|
||||
("Proc-Type", "4,ENCRYPTED"),
|
||||
("DEK-Info", "UNKNOWN-CIPHER,00000000000000000000000000000000"),
|
||||
],
|
||||
true,
|
||||
),
|
||||
] {
|
||||
let mut block = pem::Pem::new("RSA PRIVATE KEY", b"secret-invalid-key-material");
|
||||
for (name, value) in headers {
|
||||
block.headers_mut().add(name, value).unwrap();
|
||||
}
|
||||
fs::write(&key, pem::encode(&block)).unwrap();
|
||||
for password in [None, Some("secret-passphrase")] {
|
||||
let error = load(&fixture("rsa-cert.pem"), &key, password).unwrap_err();
|
||||
match error.downcast_ref::<RequestIdentityError>() {
|
||||
Some(RequestIdentityError::UnsupportedEncryption) => assert!(unsupported),
|
||||
Some(RequestIdentityError::InvalidKey) => assert!(!unsupported),
|
||||
other => panic!("unexpected traditional header error: {other:?}"),
|
||||
}
|
||||
let diagnostic = format!("{error:?}");
|
||||
for secret in ["secret-invalid-key-material", "secret-passphrase", "invalid-secret-iv"] {
|
||||
assert!(!diagnostic.contains(secret));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn der_with_trailing_data_is_rejected_for_certificates_and_keys() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let source = directory.path().join("trailing.der");
|
||||
for name in [
|
||||
"rsa-cert.pem",
|
||||
"rsa-pkcs1.pem",
|
||||
"rsa-pkcs8.pem",
|
||||
"rsa-pbes2-sha256.pem",
|
||||
"ec-sec1.pem",
|
||||
] {
|
||||
let mut der = pem::parse(bytes(name)).unwrap().into_contents();
|
||||
der.push(0);
|
||||
fs::write(&source, der).unwrap();
|
||||
let result = if name == "rsa-cert.pem" {
|
||||
load(&source, &fixture("rsa-pkcs8.pem"), Some(PASSWORD))
|
||||
} else {
|
||||
load(&fixture("rsa-cert.pem"), &source, Some(PASSWORD))
|
||||
};
|
||||
let error = result.unwrap_err();
|
||||
assert!(
|
||||
matches!(
|
||||
error.downcast_ref::<RequestIdentityError>(),
|
||||
Some(RequestIdentityError::InvalidKey | RequestIdentityError::InvalidCertificate)
|
||||
),
|
||||
"{name}: {error}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pkcs12_extensions_are_ascii_case_insensitive() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let archive = bytes("modern.p12");
|
||||
for extension in ["P12", "p12", "PFX", "pFx"] {
|
||||
let path = directory.path().join(format!("identity.{extension}"));
|
||||
fs::write(&path, &archive).unwrap();
|
||||
let identity = ClientIdentity::load(path.to_str().unwrap(), None, Some(PASSWORD)).unwrap();
|
||||
assert_eq!(identity.certificate_data(), archive);
|
||||
assert!(identity.key_data().is_none());
|
||||
for password in [None, Some("incorrect")] {
|
||||
let error = ClientIdentity::load(path.to_str().unwrap(), None, password).unwrap_err();
|
||||
match error.downcast_ref::<RequestIdentityError>() {
|
||||
Some(RequestIdentityError::NoPassphrase("PKCS#12")) => assert!(password.is_none()),
|
||||
Some(RequestIdentityError::InvalidPkcs12(_)) => assert!(password.is_some()),
|
||||
other => panic!("unexpected archive error: {other:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user