pingora_openssl::ssl

Struct SslContext

Source
pub struct SslContext(/* private fields */);
Expand description

A context object for TLS streams.

Applications commonly configure a single SslContext that is shared by all of its SslStreams.

Implementations§

Source§

impl SslContext

Source

pub fn builder(method: SslMethod) -> Result<SslContextBuilder, ErrorStack>

Creates a new builder object for an SslContext.

Source

pub fn new_ex_index<T>() -> Result<Index<SslContext, T>, ErrorStack>
where T: 'static + Sync + Send,

Returns a new extra data index.

Each invocation of this function is guaranteed to return a distinct index. These can be used to store data in the context that can be retrieved later by callbacks, for example.

This corresponds to SSL_CTX_get_ex_new_index.

Methods from Deref<Target = SslContextRef>§

Source

pub fn certificate(&self) -> Option<&X509Ref>

Returns the certificate associated with this SslContext, if present.

Requires OpenSSL 1.0.2 or LibreSSL 2.7.0 or newer.

This corresponds to SSL_CTX_get0_certificate.

Source

pub fn private_key(&self) -> Option<&PKeyRef<Private>>

Returns the private key associated with this SslContext, if present.

Requires OpenSSL 1.0.2 or LibreSSL 3.4.0 or newer.

This corresponds to SSL_CTX_get0_privatekey.

Source

pub fn cert_store(&self) -> &X509StoreRef

Returns a shared reference to the certificate store used for verification.

This corresponds to SSL_CTX_get_cert_store.

Source

pub fn extra_chain_certs(&self) -> &StackRef<X509>

Returns a shared reference to the stack of certificates making up the chain from the leaf.

This corresponds to SSL_CTX_get_extra_chain_certs.

Source

pub fn ex_data<T>(&self, index: Index<SslContext, T>) -> Option<&T>

Returns a reference to the extra data at the specified index.

This corresponds to SSL_CTX_get_ex_data.

Source

pub fn max_early_data(&self) -> u32

Gets the maximum amount of early data that will be accepted on incoming connections.

Requires OpenSSL 1.1.1 or LibreSSL 3.4.0 or newer.

This corresponds to SSL_CTX_get_max_early_data.

Source

pub unsafe fn add_session(&self, session: &SslSessionRef) -> bool

Adds a session to the context’s cache.

Returns true if the session was successfully added to the cache, and false if it was already present.

§Safety

The caller of this method is responsible for ensuring that the session has never been used with another SslContext than this one.

This corresponds to SSL_CTX_add_session.

Source

pub unsafe fn remove_session(&self, session: &SslSessionRef) -> bool

Removes a session from the context’s cache and marks it as non-resumable.

Returns true if the session was successfully found and removed, and false otherwise.

§Safety

The caller of this method is responsible for ensuring that the session has never been used with another SslContext than this one.

This corresponds to SSL_CTX_remove_session.

Source

pub fn session_cache_size(&self) -> i64

Returns the context’s session cache size limit.

A value of 0 means that the cache size is unbounded.

This corresponds to SSL_CTX_sess_get_cache_size.

Source

pub fn verify_mode(&self) -> SslVerifyMode

Returns the verify mode that was set on this context from SslContextBuilder::set_verify.

This corresponds to SSL_CTX_get_verify_mode.

Source

pub fn num_tickets(&self) -> usize

Gets the number of TLS 1.3 session tickets that will be sent to a client after a full handshake.

Requires OpenSSL 1.1.1 or newer.

This corresponds to SSL_CTX_get_num_tickets.

Source

pub fn security_level(&self) -> u32

Get the context’s security level, which controls the allowed parameters and algorithms.

Requires OpenSSL 1.1.0 or newer.

This corresponds to SSL_CTX_get_security_level.

Trait Implementations§

Source§

impl AsRef<SslContextRef> for SslContext

Source§

fn as_ref(&self) -> &SslContextRef

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<SslContextRef> for SslContext

Source§

fn borrow(&self) -> &SslContextRef

Immutably borrows from an owned value. Read more
Source§

impl Clone for SslContext

Source§

fn clone(&self) -> SslContext

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SslContext

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Deref for SslContext

Source§

type Target = SslContextRef

The resulting type after dereferencing.
Source§

fn deref(&self) -> &SslContextRef

Dereferences the value.
Source§

impl DerefMut for SslContext

Source§

fn deref_mut(&mut self) -> &mut SslContextRef

Mutably dereferences the value.
Source§

impl Drop for SslContext

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl ForeignType for SslContext

Source§

type CType = SSL_CTX

The raw C type.
Source§

type Ref = SslContextRef

The type representing a reference to this type.
Source§

unsafe fn from_ptr(ptr: *mut SSL_CTX) -> SslContext

Constructs an instance of this type from its raw type.
Source§

fn as_ptr(&self) -> *mut SSL_CTX

Returns a raw pointer to the wrapped value.
Source§

impl Send for SslContext

Source§

impl Sync for SslContext

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.