Struct security_framework::secure_transport::SslContext[][src]

pub struct SslContext(_);
Expand description

A Secure Transport SSL/TLS context object.

Implementations

impl SslContext[src]

pub fn new(
    side: SslProtocolSide,
    type_: SslConnectionType
) -> Result<SslContext>
[src]

Creates a new SslContext for the specified side and type of SSL connection.

pub fn set_peer_domain_name(&mut self, peer_name: &str) -> Result<()>[src]

Sets the fully qualified domain name of the peer.

This will be used on the client side of a session to validate the common name field of the server’s certificate. It has no effect if called on a server-side SslContext.

It is highly recommended to call this method before starting the handshake process.

pub fn peer_domain_name(&self) -> Result<String>[src]

Returns the peer domain name set by set_peer_domain_name.

pub fn set_certificate(
    &mut self,
    identity: &SecIdentity,
    certs: &[SecCertificate]
) -> Result<()>
[src]

Sets the certificate to be used by this side of the SSL session.

This must be called before the handshake for server-side connections, and can be used on the client-side to specify a client certificate.

The identity corresponds to the leaf certificate and private key, and the certs correspond to extra certificates in the chain.

pub fn set_peer_id(&mut self, peer_id: &[u8]) -> Result<()>[src]

Sets the peer ID of this session.

A peer ID is an opaque sequence of bytes that will be used by Secure Transport to identify the peer of an SSL session. If the peer ID of this session matches that of a previously terminated session, the previous session can be resumed without requiring a full handshake.

pub fn peer_id(&self) -> Result<Option<&[u8]>>[src]

Returns the peer ID of this session.

pub fn supported_ciphers(&self) -> Result<Vec<CipherSuite>>[src]

Returns the list of ciphers that are supported by Secure Transport.

pub fn enabled_ciphers(&self) -> Result<Vec<CipherSuite>>[src]

Returns the list of ciphers that are eligible to be used for negotiation.

pub fn set_enabled_ciphers(&mut self, ciphers: &[CipherSuite]) -> Result<()>[src]

Sets the list of ciphers that are eligible to be used for negotiation.

pub fn negotiated_cipher(&self) -> Result<CipherSuite>[src]

Returns the cipher being used by the session.

pub fn set_client_side_authenticate(
    &mut self,
    auth: SslAuthenticate
) -> Result<()>
[src]

Sets the requirements for client certificates.

Should only be called on server-side sessions.

pub fn client_certificate_state(&self) -> Result<SslClientCertificateState>[src]

Returns the state of client certificate processing.

pub fn peer_trust2(&self) -> Result<Option<SecTrust>>[src]

Returns the SecTrust object corresponding to the peer.

This can be used in conjunction with set_break_on_server_auth to validate certificates which do not have roots in the default set.

pub fn peer_trust(&self) -> Result<SecTrust>[src]

👎 Deprecated since 0.2.1:

use peer_trust2 instead

pub fn state(&self) -> Result<SessionState>[src]

Returns the state of the session.

pub fn negotiated_protocol_version(&self) -> Result<SslProtocol>[src]

Returns the protocol version being used by the session.

pub fn protocol_version_max(&self) -> Result<SslProtocol>[src]

Returns the maximum protocol version allowed by the session.

pub fn set_protocol_version_max(
    &mut self,
    max_version: SslProtocol
) -> Result<()>
[src]

Sets the maximum protocol version allowed by the session.

pub fn protocol_version_min(&self) -> Result<SslProtocol>[src]

Returns the minimum protocol version allowed by the session.

pub fn set_protocol_version_min(
    &mut self,
    min_version: SslProtocol
) -> Result<()>
[src]

Sets the minimum protocol version allowed by the session.

pub fn set_protocol_version_enabled(
    &mut self,
    protocol: SslProtocol,
    enabled: bool
) -> Result<()>
[src]

Sets whether a protocol is enabled or not.

Note

On OSX this is a deprecated API in favor of set_protocol_version_max and set_protocol_version_min, although if you’re working with OSX 10.8 or before you may have to use this API instead.

pub fn buffered_read_size(&self) -> Result<usize>[src]

Returns the number of bytes which can be read without triggering a read call in the underlying stream.

pub fn set_break_on_server_auth(&mut self, value: bool) -> Result<()>[src]

If enabled, the handshake process will pause and return instead of automatically validating a server’s certificate.

pub fn break_on_server_auth(&self) -> Result<bool>[src]

If enabled, the handshake process will pause and return instead of automatically validating a server’s certificate.

pub fn set_break_on_cert_requested(&mut self, value: bool) -> Result<()>[src]

If enabled, the handshake process will pause and return after the server requests a certificate from the client.

pub fn break_on_cert_requested(&self) -> Result<bool>[src]

If enabled, the handshake process will pause and return after the server requests a certificate from the client.

pub fn set_break_on_client_auth(&mut self, value: bool) -> Result<()>[src]

If enabled, the handshake process will pause and return instead of automatically validating a client’s certificate.

pub fn break_on_client_auth(&self) -> Result<bool>[src]

If enabled, the handshake process will pause and return instead of automatically validating a client’s certificate.

pub fn handshake<S>(self, stream: S) -> Result<SslStream<S>, HandshakeError<S>> where
    S: Read + Write
[src]

Performs the SSL/TLS handshake.

Trait Implementations

impl Clone for SslContext[src]

fn clone(&self) -> SslContext[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for SslContext[src]

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

Formats the value using the given formatter. Read more

impl Drop for SslContext[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

impl PartialEq<SslContext> for SslContext[src]

fn eq(&self, other: &SslContext) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests for !=.

impl SslContextExt for SslContext[src]

fn diffie_hellman_params(&self) -> Result<Option<&[u8]>>[src]

Returns the DER encoded data specifying the parameters used for Diffie-Hellman key exchange. Read more

fn set_diffie_hellman_params(&mut self, dh_params: &[u8]) -> Result<()>[src]

Sets the parameters used for Diffie-Hellman key exchange, in the DER format used by OpenSSL. Read more

fn certificate_authorities(&self) -> Result<Option<Vec<SecCertificate>>>[src]

Returns the certificate authorities used to validate client certificates. Read more

fn set_certificate_authorities(
    &mut self,
    certs: &[SecCertificate]
) -> Result<()>
[src]

Sets the certificate authorities used to validate client certificates, replacing any that are already present. Read more

fn add_certificate_authorities(
    &mut self,
    certs: &[SecCertificate]
) -> Result<()>
[src]

Adds certificate authorities used to validate client certificates.

impl TCFType for SslContext[src]

type Ref = SSLContextRef

The reference type wrapped inside this type.

fn as_concrete_TypeRef(&self) -> SSLContextRef[src]

Returns the object as its concrete TypeRef.

unsafe fn wrap_under_get_rule(reference: SSLContextRef) -> Self[src]

Returns an instance of the object, wrapping the underlying CFTypeRef subclass. Use this when following Core Foundation’s “Get Rule”. The reference count is bumped. Read more

fn as_CFTypeRef(&self) -> CFTypeRef[src]

Returns the object as a raw CFTypeRef. The reference count is not adjusted.

unsafe fn wrap_under_create_rule(reference: SSLContextRef) -> Self[src]

Returns an instance of the object, wrapping the underlying CFTypeRef subclass. Use this when following Core Foundation’s “Create Rule”. The reference count is not bumped. Read more

fn type_id() -> CFTypeID[src]

Returns the type ID for this class.

fn as_CFType(&self) -> CFType[src]

Returns the object as a wrapped CFType. The reference count is incremented by one.

fn into_CFType(self) -> CFType[src]

Returns the object as a wrapped CFType. Consumes self and avoids changing the reference count. Read more

fn retain_count(&self) -> i64[src]

Returns the reference count of the object. It is unwise to do anything other than test whether the return value of this method is greater than zero. Read more

fn type_of(&self) -> u64[src]

Returns the type ID of this object.

fn show(&self)[src]

Writes a debugging version of this object on standard error.

fn instance_of<OtherCFType>(&self) -> bool where
    OtherCFType: TCFType
[src]

Returns true if this value is an instance of another type.

impl<'a> ToVoid<SslContext> for &'a SslContext[src]

impl ToVoid<SslContext> for SslContext[src]

impl ConcreteCFType for SslContext[src]

impl Eq for SslContext[src]

impl Send for SslContext[src]

impl Sync for SslContext[src]

Auto Trait Implementations

impl RefUnwindSafe for SslContext

impl Unpin for SslContext

impl UnwindSafe for SslContext

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> FromMutVoid for T where
    T: TCFType
[src]

pub unsafe fn from_mut_void<'a>(x: *mut c_void) -> ItemMutRef<'a, T>[src]

impl<T> FromVoid for T where
    T: TCFType
[src]

pub unsafe fn from_void<'a>(x: *const c_void) -> ItemRef<'a, T>[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.