Skip to content

Commit c52c09e

Browse files
authored
Merge pull request #129 from syedriko/syedriko-log-3398
LOG-3398: Apply TLSSecurityProfile settings to TLS listeners in log collectors
2 parents 427ddec + 8f2c4af commit c52c09e

Some content is hidden

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

88 files changed

+39
-3
lines changed

Cargo.lock

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ chrono = { git = "https://github.com/vectordotdev/chrono.git", branch = "no-defa
337337
aws-config = { path = "patch/aws-config" }
338338
aws-sigv4 = { path = "patch/aws-sigv4" }
339339
hyper-openssl = { path = "patch/hyper-openssl" }
340+
openssl = { path = "patch/openssl" }
340341

341342
[features]
342343
ocp-logging = [

Dockerfile.unit

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM registry.redhat.io/ubi8:8.6-754 as builder
33
RUN INSTALL_PKGS=" \
44
cmake \
55
libarchive \
6+
gcc-c++ \
67
make \
78
git \
89
openssl-devel \
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

vendor/openssl/src/ssl/connector.rs patch/openssl/src/ssl/connector.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::dh::Dh;
66
use crate::error::ErrorStack;
77
use crate::ssl::{
88
HandshakeError, Ssl, SslContext, SslContextBuilder, SslContextRef, SslMethod, SslMode,
9-
SslOptions, SslRef, SslStream, SslVerifyMode,
9+
SslOptions, SslRef, SslStream, SslVerifyMode, SslVersion,
1010
};
1111
use crate::version;
1212

@@ -217,6 +217,28 @@ impl DerefMut for ConnectConfiguration {
217217
pub struct SslAcceptor(SslContext);
218218

219219
impl SslAcceptor {
220+
pub fn custom(method: SslMethod, min_tls_version: &String, ciphersuites: &String) -> Result<SslAcceptorBuilder, ErrorStack> {
221+
let mut ctx = ctx(method)?;
222+
let min_proto_version: SslVersion;
223+
match min_tls_version.as_str() {
224+
"VersionTLS10" => min_proto_version = SslVersion::TLS1,
225+
"VersionTLS11" => min_proto_version = SslVersion::TLS1_1,
226+
"VersionTLS12" => min_proto_version = SslVersion::TLS1_2,
227+
"VersionTLS13" => min_proto_version = SslVersion::TLS1_3,
228+
_ => min_proto_version = SslVersion::TLS1,
229+
}
230+
ctx.set_min_proto_version(Some(min_proto_version))?;
231+
let dh = Dh::params_from_pem(FFDHE_2048.as_bytes())?;
232+
ctx.set_tmp_dh(&dh)?;
233+
setup_curves(&mut ctx)?;
234+
ctx.set_cipher_list(ciphersuites.replace(",", ":").as_str())?;
235+
#[cfg(ossl111)]
236+
ctx.set_ciphersuites(
237+
"TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256",
238+
)?;
239+
Ok(SslAcceptorBuilder(ctx))
240+
}
241+
220242
/// Creates a new builder configured to connect to non-legacy clients. This should generally be
221243
/// considered a reasonable default choice.
222244
///
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/tls/incoming.rs

+8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ impl TlsSettings {
3030
match self.identity {
3131
None => Err(TlsError::MissingRequiredIdentity),
3232
Some(_) => {
33+
if let Some(min_tls_version) = &self.min_tls_version {
34+
if let Some (ciphersuites) = &self.ciphersuites {
35+
let mut acceptor = SslAcceptor::custom(SslMethod::tls(), min_tls_version, ciphersuites)
36+
.context(CreateAcceptorSnafu)?;
37+
self.apply_context(&mut acceptor)?;
38+
return Ok(acceptor.build())
39+
}
40+
}
3341
let mut acceptor = SslAcceptor::mozilla_intermediate_v5(SslMethod::tls())
3442
.context(CreateAcceptorSnafu)?;
3543
self.apply_context(&mut acceptor)?;

src/tls/settings.rs

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ pub struct TlsOptions {
6868
#[serde(alias = "key_path")]
6969
pub key_file: Option<PathBuf>,
7070
pub key_pass: Option<String>,
71+
pub min_tls_version: Option<String>,
72+
pub ciphersuites: Option<String>,
7173
}
7274

7375
impl TlsOptions {
@@ -89,6 +91,8 @@ pub struct TlsSettings {
8991
pub(super) verify_hostname: bool,
9092
authorities: Vec<X509>,
9193
pub(super) identity: Option<IdentityStore>, // openssl::pkcs12::ParsedPkcs12 doesn't impl Clone yet
94+
pub min_tls_version: Option<String>,
95+
pub ciphersuites: Option<String>,
9296
}
9397

9498
#[derive(Clone)]
@@ -125,6 +129,8 @@ impl TlsSettings {
125129
verify_hostname: options.verify_hostname.unwrap_or(!for_server),
126130
authorities: options.load_authorities()?,
127131
identity: options.load_identity()?,
132+
min_tls_version: options.min_tls_version.clone(),
133+
ciphersuites: options.ciphersuites.clone(),
128134
})
129135
}
130136

0 commit comments

Comments
 (0)