Struct openssl::ssl::SslContext
source · [−]pub struct SslContext(_);
Expand description
A context object for TLS streams.
Applications commonly configure a single SslContext
that is shared by all of its
SslStreams
.
Implementations
sourceimpl SslContext
impl SslContext
sourcepub fn builder(method: SslMethod) -> Result<SslContextBuilder, ErrorStack>
pub fn builder(method: SslMethod) -> Result<SslContextBuilder, ErrorStack>
Creates a new builder object for an SslContext
.
sourcepub fn new_ex_index<T>() -> Result<Index<SslContext, T>, ErrorStack> where
T: 'static + Sync + Send,
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>
sourcepub fn certificate(&self) -> Option<&X509Ref>
pub fn certificate(&self) -> Option<&X509Ref>
Returns the certificate associated with this SslContext
, if present.
Requires OpenSSL 1.0.2 or newer.
This corresponds to SSL_CTX_get0_certificate
.
sourcepub fn private_key(&self) -> Option<&PKeyRef<Private>>
pub fn private_key(&self) -> Option<&PKeyRef<Private>>
Returns the private key associated with this SslContext
, if present.
Requires OpenSSL 1.0.2 or newer.
This corresponds to SSL_CTX_get0_privatekey
.
sourcepub fn cert_store(&self) -> &X509StoreRef
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
.
sourcepub fn extra_chain_certs(&self) -> &StackRef<X509>
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
.
sourcepub fn ex_data<T>(&self, index: Index<SslContext, T>) -> Option<&T>
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
.
sourcepub fn max_early_data(&self) -> u32
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 newer.
This corresponds to SSL_CTX_get_max_early_data
.
sourcepub unsafe fn add_session(&self, session: &SslSessionRef) -> bool
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.
This corresponds to SSL_CTX_add_session
.
Safety
The caller of this method is responsible for ensuring that the session has never been used with another
SslContext
than this one.
sourcepub unsafe fn remove_session(&self, session: &SslSessionRef) -> bool
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.
This corresponds to SSL_CTX_remove_session
.
Safety
The caller of this method is responsible for ensuring that the session has never been used with another
SslContext
than this one.
sourcepub fn session_cache_size(&self) -> i64
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
.
sourcepub fn verify_mode(&self) -> SslVerifyMode
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
.
Trait Implementations
sourceimpl AsRef<SslContextRef> for SslContext
impl AsRef<SslContextRef> for SslContext
sourcefn as_ref(&self) -> &SslContextRef
fn as_ref(&self) -> &SslContextRef
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl Borrow<SslContextRef> for SslContext
impl Borrow<SslContextRef> for SslContext
sourcefn borrow(&self) -> &SslContextRef
fn borrow(&self) -> &SslContextRef
Immutably borrows from an owned value. Read more
sourceimpl Clone for SslContext
impl Clone for SslContext
sourceimpl Debug for SslContext
impl Debug for SslContext
sourceimpl Deref for SslContext
impl Deref for SslContext
type Target = SslContextRef
type Target = SslContextRef
The resulting type after dereferencing.
sourcefn deref(&self) -> &SslContextRef
fn deref(&self) -> &SslContextRef
Dereferences the value.
sourceimpl DerefMut for SslContext
impl DerefMut for SslContext
sourcefn deref_mut(&mut self) -> &mut SslContextRef
fn deref_mut(&mut self) -> &mut SslContextRef
Mutably dereferences the value.
sourceimpl Drop for SslContext
impl Drop for SslContext
sourceimpl ForeignType for SslContext
impl ForeignType for SslContext
type Ref = SslContextRef
type Ref = SslContextRef
The type representing a reference to this type.
sourceunsafe fn from_ptr(ptr: *mut SSL_CTX) -> SslContext
unsafe fn from_ptr(ptr: *mut SSL_CTX) -> SslContext
Constructs an instance of this type from its raw type.
impl Send for SslContext
impl Sync for SslContext
Auto Trait Implementations
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more