Make rpk feature flag additive

This commit is contained in:
Kornel 2025-09-26 18:09:24 +01:00 committed by Alessandro Ghedini
parent 1c51c7ee3b
commit 4ce1308e1c
1 changed files with 15 additions and 31 deletions

View File

@ -858,7 +858,11 @@ impl SslContextBuilder {
init();
let ctx = cvt_p(ffi::SSL_CTX_new(SslMethod::tls_with_buffer().as_ptr()))?;
Ok(SslContextBuilder::from_ptr(ctx, true))
let mut builder = SslContextBuilder::from_ptr(ctx);
builder.is_rpk = true;
builder.set_ex_data(*RPK_FLAG_INDEX, true);
Ok(builder)
}
}
@ -897,48 +901,28 @@ impl SslContextBuilder {
unsafe {
init();
let ctx = cvt_p(ffi::SSL_CTX_new(method.as_ptr()))?;
#[cfg(feature = "rpk")]
{
Ok(SslContextBuilder::from_ptr(ctx, false))
}
#[cfg(not(feature = "rpk"))]
{
Ok(SslContextBuilder::from_ptr(ctx))
}
}
}
/// Creates an `SslContextBuilder` from a pointer to a raw OpenSSL value.
///
#[cfg_attr(
feature = "rpk",
doc = "Keeps previous RPK state. Use `new_rpk()` to enable RPK."
)]
///
/// # Safety
///
/// The caller must ensure that the pointer is valid and uniquely owned by the builder.
#[cfg(feature = "rpk")]
pub unsafe fn from_ptr(ctx: *mut ffi::SSL_CTX, is_rpk: bool) -> SslContextBuilder {
let ctx = SslContext::from_ptr(ctx);
let mut builder = SslContextBuilder {
ctx,
is_rpk,
has_shared_cert_store: false,
};
builder.set_ex_data(*RPK_FLAG_INDEX, is_rpk);
builder
}
/// Creates an `SslContextBuilder` from a pointer to a raw OpenSSL value.
///
/// # Safety
///
/// The caller must ensure that the pointer is valid and uniquely owned by the builder.
#[cfg(not(feature = "rpk"))]
/// The context must own its cert store exclusively.
pub unsafe fn from_ptr(ctx: *mut ffi::SSL_CTX) -> SslContextBuilder {
let ctx = SslContext::from_ptr(ctx);
SslContextBuilder {
ctx: SslContext::from_ptr(ctx),
#[cfg(feature = "rpk")]
is_rpk: ctx.is_rpk(),
has_shared_cert_store: false,
ctx,
}
}