Skip to content

Commit

Permalink
Expose SSL_CTX_set1_ech_keys from SslContextRef
Browse files Browse the repository at this point in the history
We currently expose this method on `SslContextBuilder`, which is fine
for bootstrapping an `SSL_CTX`, but subsequent attempts to set ECH keys
(like during key rotation) can only happen via `SslContextRef`. Also
update the method on the builder to take an immutable reference to self
because the API is thread safe.
  • Loading branch information
rushilmehra committed Feb 19, 2025
1 parent c95d764 commit 9cada21
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion boring/src/ssl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1960,7 +1960,7 @@ impl SslContextBuilder {
/// threads.
#[cfg(not(feature = "fips"))]
#[corresponds(SSL_CTX_set1_ech_keys)]
pub fn set_ech_keys(&mut self, keys: SslEchKeys) -> Result<(), ErrorStack> {
pub fn set_ech_keys(&self, keys: SslEchKeys) -> Result<(), ErrorStack> {
unsafe { cvt(ffi::SSL_CTX_set1_ech_keys(self.as_ptr(), keys.as_ptr())).map(|_| ()) }
}

Expand Down Expand Up @@ -2210,6 +2210,16 @@ impl SslContextRef {
pub fn is_rpk(&self) -> bool {
self.ex_data(*RPK_FLAG_INDEX).copied().unwrap_or_default()
}

/// Registers a list of ECH keys on the context. This list should contain new and old
/// ECHConfigs to allow stale DNS caches to update. Unlike most `SSL_CTX` APIs, this function
/// is safe to call even after the `SSL_CTX` has been associated with connections on various
/// threads.
#[cfg(not(feature = "fips"))]
#[corresponds(SSL_CTX_set1_ech_keys)]
pub fn set_ech_keys(&self, keys: SslEchKeys) -> Result<(), ErrorStack> {
unsafe { cvt(ffi::SSL_CTX_set1_ech_keys(self.as_ptr(), keys.as_ptr())).map(|_| ()) }
}
}

/// Error returned by the callback to get a session when operation
Expand Down

0 comments on commit 9cada21

Please sign in to comment.