mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 14:36:15 -05:00
chore: promote GP Connect 3.3.1 sources and Nix packages (#699)
* 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. * fix: select PKCS12 issuers by certificate signature Handle CA rollover and self-issued intermediates by checking issuer signatures. Preserve RSA-PSS signature parameters during GnuTLS verification and keep the original archive for OpenConnect. Add mutual-TLS regression coverage for certificate bag order and RSA-PSS salt lengths. Verified 53 targeted tests plus gpapi, desktop-core, and iOS compile checks. * fix: add gateway login diagnostics and scope platform dependencies * chore: prepare GP Connect 3.3.1 release
This commit is contained in:
1 parent
e03a758acb
commit
408536807c
55 files changed
+3288
-203
No files matched your search
@@ -1,11 +1,22 @@
|
||||
use std::ffi::{c_char, c_int};
|
||||
|
||||
use pkcs8::SecretDocument;
|
||||
use pkcs8::der::{Encode, asn1::ObjectIdentifier};
|
||||
use zeroize::Zeroizing;
|
||||
|
||||
use crate::utils::request::RequestIdentityError;
|
||||
|
||||
unsafe extern "C" {
|
||||
fn gp_certificate_verify_signature(
|
||||
certificate: *const u8,
|
||||
certificate_length: usize,
|
||||
issuer_key: *const u8,
|
||||
issuer_key_length: usize,
|
||||
message: *const u8,
|
||||
message_length: usize,
|
||||
signature: *const u8,
|
||||
signature_length: usize,
|
||||
) -> c_int;
|
||||
fn gp_key_import(
|
||||
input: *const u8,
|
||||
length: usize,
|
||||
@@ -14,9 +25,58 @@ 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);
|
||||
}
|
||||
|
||||
pub(super) fn verify_certificate_signature(
|
||||
certificate: &x509_cert::Certificate,
|
||||
issuer: &x509_cert::Certificate,
|
||||
message: &[u8],
|
||||
signature: &[u8],
|
||||
) -> anyhow::Result<bool> {
|
||||
const RSA: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.1");
|
||||
const RSA_PSS: ObjectIdentifier = ObjectIdentifier::new_unwrap("1.2.840.113549.1.1.10");
|
||||
let mut issuer_key = issuer.tbs_certificate().subject_public_key_info().clone();
|
||||
if certificate.signature_algorithm().oid == RSA_PSS {
|
||||
if !matches!(issuer_key.algorithm.oid, RSA | RSA_PSS) {
|
||||
return Ok(false);
|
||||
}
|
||||
// GnuTLS's generic verifier takes PSS parameters from the imported key.
|
||||
// Give this verification operation the certificate's full AlgorithmIdentifier,
|
||||
// including salt length, rather than the default implied by its signature enum.
|
||||
// This temporary SPKI never changes the certificates sent to the server.
|
||||
issuer_key.algorithm = certificate.signature_algorithm().clone();
|
||||
}
|
||||
let issuer_key = issuer_key.to_der()?;
|
||||
let certificate = certificate.to_der()?;
|
||||
let result = unsafe {
|
||||
gp_certificate_verify_signature(
|
||||
certificate.as_ptr(),
|
||||
certificate.len(),
|
||||
issuer_key.as_ptr(),
|
||||
issuer_key.len(),
|
||||
message.as_ptr(),
|
||||
message.len(),
|
||||
signature.as_ptr(),
|
||||
signature.len(),
|
||||
)
|
||||
};
|
||||
match result {
|
||||
0 => Ok(false),
|
||||
1 => Ok(true),
|
||||
_ => Err(RequestIdentityError::InvalidCertificate.into()),
|
||||
}
|
||||
}
|
||||
|
||||
struct ExportedKey {
|
||||
data: *mut u8,
|
||||
length: usize,
|
||||
@@ -64,3 +124,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