Skip to content

Commit 144ebec

Browse files
vparfonovclaude
andcommitted
fix: remove patched openssl crate, use upstream API for TLS security profiles (LOG-3398)
Replace the forked patch/openssl crate with direct calls to the upstream openssl crate's public API (set_min_proto_version, set_cipher_list, set_ciphersuites). This eliminates ~70 patched files and reduces the maintenance burden on upstream version bumps while preserving dynamic linking to system OpenSSL for FIPS compliance. The TLS security profile logic (min_tls_version, ciphersuites) is now implemented in Vector's own TLS module via apply_tls_security_profile(), and is wired into apply_context_base() where it was previously stored but never applied in production code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b2e58e8 commit 144ebec

111 files changed

Lines changed: 120 additions & 37947 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ async-nats = { version = "0.42.0", default-features = false, optional = true, fe
407407
nkeys = { version = "0.4.5", default-features = false, optional = true }
408408
nom = { workspace = true, optional = true }
409409
notify = { version = "8.1.0", default-features = false, features = ["macos_fsevent"] }
410-
openssl = { version = "0.10.73", default-features = false}
410+
openssl = { version = "0.10.75", default-features = false}
411411
openssl-probe = { version = "0.1.6", default-features = false }
412412
ordered-float.workspace = true
413413
percent-encoding = { version = "2.3.1", default-features = false }
@@ -500,7 +500,6 @@ zstd = { version = "0.13.0", default-features = false }
500500
# The `heim` crates depend on `ntapi` 0.3.7 on Windows, but that version has an
501501
# unaligned access bug fixed in the following revision.
502502
ntapi = { git = "https://github.com/MSxDOS/ntapi.git", rev = "24fc1e47677fc9f6e38e5f154e6011dc9b270da6" }
503-
openssl = { path = "patch/openssl" }
504503
hyper = { path = "patch/hyper" }
505504

506505
[features]

lib/vector-core/src/tls/mod.rs

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{fmt::Debug, net::SocketAddr, num::TryFromIntError, path::PathBuf, time
44

55
use openssl::{
66
error::ErrorStack,
7-
ssl::{ConnectConfiguration, SslConnector, SslConnectorBuilder, SslMethod},
7+
ssl::{ConnectConfiguration, SslConnector, SslConnectorBuilder, SslMethod, SslVersion},
88
};
99
use snafu::{ResultExt, Snafu};
1010
use tokio::net::TcpStream;
@@ -131,6 +131,16 @@ pub enum TlsError {
131131
NewCaStack { source: ErrorStack },
132132
#[snafu(display("Could not push intermediate certificate onto stack"))]
133133
CaStackPush { source: ErrorStack },
134+
// BEGIN RED HAT - TLS security profile support (LOG-3398)
135+
#[snafu(display("Invalid TLS version: {}", version))]
136+
InvalidTlsVersion { version: String },
137+
#[snafu(display("Invalid or empty ciphersuite string"))]
138+
InvalidCiphersuite,
139+
#[snafu(display("Could not set minimum TLS version: {}", source))]
140+
SetMinTlsVersion { source: ErrorStack },
141+
#[snafu(display("Could not set cipher list: {}", source))]
142+
SetCipherList { source: ErrorStack },
143+
// END RED HAT - TLS security profile support (LOG-3398)
134144
}
135145

136146
impl MaybeTlsStream<TcpStream> {
@@ -175,6 +185,47 @@ impl MaybeTlsStream<TcpStream> {
175185
}
176186
}
177187

188+
// BEGIN RED HAT - TLS security profile support (LOG-3398)
189+
/// Apply TLS security profile settings (min version, ciphersuites) to an SSL context builder.
190+
///
191+
/// Maps `OpenShift` TLS security profile version strings (`VersionTLS10`..`VersionTLS13`)
192+
/// to OpenSSL protocol versions and configures ciphersuites accordingly.
193+
pub fn apply_tls_security_profile(
194+
ctx: &mut openssl::ssl::SslContextBuilder,
195+
min_tls_version: &Option<String>,
196+
ciphersuites: &Option<String>,
197+
) -> Result<()> {
198+
let mut resolved_version = SslVersion::TLS1;
199+
if let Some(version_str) = min_tls_version {
200+
resolved_version = match version_str.as_str() {
201+
"VersionTLS10" => SslVersion::TLS1,
202+
"VersionTLS11" => SslVersion::TLS1_1,
203+
"VersionTLS12" => SslVersion::TLS1_2,
204+
"VersionTLS13" => SslVersion::TLS1_3,
205+
_ => {
206+
return Err(TlsError::InvalidTlsVersion {
207+
version: version_str.clone(),
208+
});
209+
}
210+
};
211+
ctx.set_min_proto_version(Some(resolved_version))
212+
.context(SetMinTlsVersionSnafu)?;
213+
}
214+
if let Some(suites) = ciphersuites {
215+
if suites.is_empty() {
216+
return Err(TlsError::InvalidCiphersuite);
217+
}
218+
let suites = suites.replace(',', ":");
219+
if resolved_version == SslVersion::TLS1_3 {
220+
ctx.set_ciphersuites(&suites).context(SetCipherListSnafu)?;
221+
} else {
222+
ctx.set_cipher_list(&suites).context(SetCipherListSnafu)?;
223+
}
224+
}
225+
Ok(())
226+
}
227+
// END RED HAT - TLS security profile support (LOG-3398)
228+
178229
pub fn tls_connector_builder(settings: &MaybeTlsSettings) -> Result<SslConnectorBuilder> {
179230
let mut builder = SslConnector::builder(SslMethod::tls()).context(TlsBuildConnectorSnafu)?;
180231
if let Some(settings) = settings.tls() {

lib/vector-core/src/tls/settings.rs

Lines changed: 61 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,25 @@ use std::{
66
};
77

88
use super::{
9-
AddCertToStoreSnafu, AddExtraChainCertSnafu, CaStackPushSnafu, EncodeAlpnProtocolsSnafu,
10-
FileOpenFailedSnafu, FileReadFailedSnafu, MaybeTls, NewCaStackSnafu, NewStoreBuilderSnafu,
11-
ParsePkcs12Snafu, PrivateKeyParseSnafu, Result, SetAlpnProtocolsSnafu, SetCertificateSnafu,
12-
SetPrivateKeySnafu, SetVerifyCertSnafu, TlsError, X509ParseSnafu,
9+
AddCertToStoreSnafu,
10+
AddExtraChainCertSnafu,
11+
CaStackPushSnafu,
12+
EncodeAlpnProtocolsSnafu,
13+
FileOpenFailedSnafu,
14+
FileReadFailedSnafu,
15+
MaybeTls,
16+
NewCaStackSnafu,
17+
NewStoreBuilderSnafu,
18+
ParsePkcs12Snafu,
19+
PrivateKeyParseSnafu,
20+
Result,
21+
SetAlpnProtocolsSnafu,
22+
SetCertificateSnafu,
23+
SetPrivateKeySnafu,
24+
SetVerifyCertSnafu,
25+
TlsError,
26+
X509ParseSnafu,
27+
apply_tls_security_profile, // RED HAT - TLS security profile support (LOG-3398)
1328
};
1429
use cfg_if::cfg_if;
1530
use lookup::lookup_v2::OptionalValuePath;
@@ -157,11 +172,13 @@ pub struct TlsConfig {
157172
#[configurable(metadata(docs::human_name = "Server Name"))]
158173
pub server_name: Option<String>,
159174

175+
// BEGIN RED HAT - TLS security profile support (LOG-3398)
160176
/// Minimal enabled TLS version.
161177
pub min_tls_version: Option<String>,
162178

163179
/// TLS ciphersuites to enable.
164180
pub ciphersuites: Option<String>,
181+
// END RED HAT - TLS security profile support (LOG-3398)
165182
}
166183

167184
impl TlsConfig {
@@ -184,8 +201,10 @@ pub struct TlsSettings {
184201
pub(super) identity: Option<IdentityStore>,
185202
alpn_protocols: Option<Vec<u8>>,
186203
server_name: Option<String>,
204+
// BEGIN RED HAT - TLS security profile support (LOG-3398)
187205
pub min_tls_version: Option<String>,
188206
pub ciphersuites: Option<String>,
207+
// END RED HAT - TLS security profile support (LOG-3398)
189208
}
190209

191210
/// Identity store in PEM format
@@ -228,6 +247,7 @@ impl TlsSettings {
228247
identity: options.load_identity()?,
229248
alpn_protocols: options.parse_alpn_protocols()?,
230249
server_name: options.server_name.clone(),
250+
// RED HAT - TLS security profile support (LOG-3398)
231251
min_tls_version: options.min_tls_version.clone(),
232252
ciphersuites: options.ciphersuites.clone(),
233253
})
@@ -347,6 +367,9 @@ impl TlsSettings {
347367
}
348368
}
349369

370+
// RED HAT - TLS security profile support (LOG-3398)
371+
apply_tls_security_profile(context, &self.min_tls_version, &self.ciphersuites)?;
372+
350373
Ok(())
351374
}
352375

@@ -662,7 +685,7 @@ fn open_read(filename: &Path, note: &'static str) -> Result<(Vec<u8>, PathBuf)>
662685

663686
#[cfg(test)]
664687
mod test {
665-
use openssl::ssl::{ErrorEx, SslMethod, SslVersion};
688+
use openssl::ssl::{SslMethod, SslVersion};
666689

667690
use super::*;
668691

@@ -831,102 +854,108 @@ mod test {
831854
assert!(config.is_tls());
832855
}
833856

857+
// BEGIN RED HAT - TLS security profile tests (LOG-3398)
834858
#[test]
835859
fn from_min_tls_version() {
836-
use std::result::Result;
860+
use super::super::apply_tls_security_profile;
837861

838862
struct TlsVersionTest {
839863
text: Option<String>,
840864
num: Option<SslVersion>,
841-
want: Result<(), ErrorEx>,
865+
want_ok: bool,
842866
}
843-
let mut builder = SslContextBuilder::new(SslMethod::tls()).unwrap();
844-
let orig_min_proto_version = builder.min_proto_version();
845867
let tests = [
846868
TlsVersionTest {
847869
text: None,
848-
num: orig_min_proto_version,
849-
want: Ok(()),
870+
num: None,
871+
want_ok: true,
850872
},
851873
TlsVersionTest {
852874
text: Some(String::new()),
853-
num: orig_min_proto_version,
854-
want: Err(ErrorEx::InvalidTlsVersion),
875+
num: None,
876+
want_ok: false,
855877
},
856878
TlsVersionTest {
857879
text: Some("foobar".to_string()),
858-
num: Some(SslVersion::TLS1),
859-
want: Err(ErrorEx::InvalidTlsVersion),
880+
num: None,
881+
want_ok: false,
860882
},
861883
TlsVersionTest {
862884
text: Some("VersionTLS10".to_string()),
863885
num: Some(SslVersion::TLS1),
864-
want: Ok(()),
886+
want_ok: true,
865887
},
866888
TlsVersionTest {
867889
text: Some("VersionTLS11".to_string()),
868890
num: Some(SslVersion::TLS1_1),
869-
want: Ok(()),
891+
want_ok: true,
870892
},
871893
TlsVersionTest {
872894
text: Some("VersionTLS12".to_string()),
873895
num: Some(SslVersion::TLS1_2),
874-
want: Ok(()),
896+
want_ok: true,
875897
},
876898
TlsVersionTest {
877899
text: Some("VersionTLS13".to_string()),
878900
num: Some(SslVersion::TLS1_3),
879-
want: Ok(()),
901+
want_ok: true,
880902
},
881903
];
882904
for t in tests {
883-
match builder.set_min_tls_version_and_ciphersuites(&t.text, &None) {
905+
let mut builder = SslContextBuilder::new(SslMethod::tls()).unwrap();
906+
let orig_min = builder.min_proto_version();
907+
match apply_tls_security_profile(&mut builder, &t.text, &None) {
884908
Ok(()) => {
885-
assert!(t.want.is_ok());
886-
assert_eq!(builder.min_proto_version(), t.num);
909+
assert!(t.want_ok, "expected error for {:?}", t.text);
910+
if let Some(expected) = t.num {
911+
assert_eq!(builder.min_proto_version(), Some(expected));
912+
} else {
913+
assert_eq!(builder.min_proto_version(), orig_min);
914+
}
887915
}
888-
Err(e) => assert_eq!(t.want.err().unwrap(), e),
916+
Err(_) => assert!(!t.want_ok, "unexpected error for {:?}", t.text),
889917
}
890918
}
891919
}
892920

893921
#[test]
894922
fn from_min_tls_version_and_ciphersuites() {
895-
use std::result::Result;
923+
use super::super::apply_tls_security_profile;
896924

897925
struct TlsCiphersuiteTest {
898926
min_tls_version: Option<String>,
899927
ciphersuite: Option<String>,
900-
want: Result<(), ErrorEx>,
928+
want_ok: bool,
901929
}
902930

903-
let mut builder = SslContextBuilder::new(SslMethod::tls()).unwrap();
904931
let tests = [
905932
TlsCiphersuiteTest {
906933
min_tls_version: Some("VersionTLS10".to_string()),
907934
ciphersuite: Some(String::new()),
908-
want: Err(ErrorEx::InvalidCiphersuite),
935+
want_ok: false,
909936
},
910937
TlsCiphersuiteTest {
911938
min_tls_version: Some("VersionTLS12".to_string()),
912939
ciphersuite: Some("AES128-SHA256".to_string()),
913-
want: Ok(()),
940+
want_ok: true,
914941
},
915942
TlsCiphersuiteTest {
916943
min_tls_version: Some("VersionTLS13".to_string()),
917944
ciphersuite: Some(
918945
"TLS_CHACHA20_POLY1305_SHA256,TLS_AES_256_GCM_SHA384".to_string(),
919946
),
920-
want: Ok(()),
947+
want_ok: true,
921948
},
922949
];
923950
for t in tests {
924-
match builder.set_min_tls_version_and_ciphersuites(&t.min_tls_version, &t.ciphersuite) {
925-
Ok(()) => assert!(t.want.is_ok()),
926-
Err(e) => assert_eq!(t.want.err().unwrap(), e),
951+
let mut builder = SslContextBuilder::new(SslMethod::tls()).unwrap();
952+
match apply_tls_security_profile(&mut builder, &t.min_tls_version, &t.ciphersuite) {
953+
Ok(()) => assert!(t.want_ok, "expected error for {:?}", t.ciphersuite),
954+
Err(_) => assert!(!t.want_ok, "unexpected error for {:?}", t.ciphersuite),
927955
}
928956
}
929957
}
958+
// END RED HAT - TLS security profile tests (LOG-3398)
930959

931960
fn settings_from_config(
932961
enabled: Option<bool>,

0 commit comments

Comments
 (0)