mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
fix: restore client certificate compatibility after OpenSSL removal
Use GnuTLS for desktop client key matching and signing without applying server certificate policy to local identities. Restore RC4 PKCS12 import and renewed certificate selection, and provide actionable unsupported identity errors. Add HTTP and OpenConnect mutual TLS regressions. Record the unresolved TLS 1.2 ECDSA hash limitation and reject P-521 and RSA-PSS keys explicitly.
This commit is contained in:
42 files changed
+2618
-163
No files matched your search
@@ -14,6 +14,15 @@ unsafe extern "C" {
|
||||
output: *mut *mut u8,
|
||||
output_length: *mut usize,
|
||||
) -> c_int;
|
||||
fn gp_pkcs12_identity(
|
||||
input: *const u8,
|
||||
length: usize,
|
||||
password: *const c_char,
|
||||
certificate: *mut *mut u8,
|
||||
certificate_length: *mut usize,
|
||||
key: *mut *mut u8,
|
||||
key_length: *mut usize,
|
||||
) -> c_int;
|
||||
fn gp_key_free(data: *mut u8, length: usize);
|
||||
}
|
||||
|
||||
@@ -64,3 +73,55 @@ pub(in crate::utils) fn decrypt(bytes: &[u8], pem: bool, passphrase: Option<&str
|
||||
_ => Err(RequestIdentityError::InvalidKey.into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::utils) fn archive(
|
||||
bytes: &[u8],
|
||||
passphrase: Option<&str>,
|
||||
) -> anyhow::Result<(Zeroizing<Vec<u8>>, SecretDocument)> {
|
||||
let mut password = Zeroizing::new(passphrase.unwrap_or_default().as_bytes().to_vec());
|
||||
anyhow::ensure!(
|
||||
!password.contains(&0),
|
||||
"PKCS#12 passphrases containing NUL are not supported"
|
||||
);
|
||||
password.push(0);
|
||||
let mut certificate = ExportedKey {
|
||||
data: std::ptr::null_mut(),
|
||||
length: 0,
|
||||
};
|
||||
let mut key = ExportedKey {
|
||||
data: std::ptr::null_mut(),
|
||||
length: 0,
|
||||
};
|
||||
let result = unsafe {
|
||||
gp_pkcs12_identity(
|
||||
bytes.as_ptr(),
|
||||
bytes.len(),
|
||||
password.as_ptr().cast(),
|
||||
&mut certificate.data,
|
||||
&mut certificate.length,
|
||||
&mut key.data,
|
||||
&mut key.length,
|
||||
)
|
||||
};
|
||||
match result {
|
||||
0 => {
|
||||
anyhow::ensure!(
|
||||
!certificate.data.is_null() && certificate.length > 0,
|
||||
"Invalid certificate file"
|
||||
);
|
||||
anyhow::ensure!(!key.data.is_null() && key.length > 0, "Invalid private key");
|
||||
let certificate =
|
||||
Zeroizing::new(unsafe { std::slice::from_raw_parts(certificate.data, certificate.length) }.to_vec());
|
||||
let key = SecretDocument::try_from(unsafe { std::slice::from_raw_parts(key.data, key.length) })
|
||||
.map_err(|_| RequestIdentityError::InvalidKey)?;
|
||||
Ok((certificate, key))
|
||||
}
|
||||
1 if passphrase.is_none() => Err(RequestIdentityError::NoPassphrase("PKCS#12").into()),
|
||||
1 => Err(RequestIdentityError::InvalidPkcs12(p12_keystore::error::Error::InvalidData).into()),
|
||||
2 => Err(RequestIdentityError::IncompletePkcs12.into()),
|
||||
3 => Err(RequestIdentityError::AmbiguousPkcs12.into()),
|
||||
4 => Err(RequestIdentityError::UnsupportedEncryption.into()),
|
||||
6 => Err(RequestIdentityError::KeyMismatch.into()),
|
||||
_ => Err(RequestIdentityError::InvalidCertificate.into()),
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user