Skip to main content

rustls_client_config

Struct rustls_client_config 

Source
pub struct rustls_client_config { /* private fields */ }
Expand description

A client config that is done being constructed and is now read-only.

Under the hood, this object corresponds to an Arc<ClientConfig>. https://docs.rs/rustls/latest/rustls/struct.ClientConfig.html

Implementations§

Source§

impl rustls_client_config

Source

#[unsafe(no_mangle)]
pub extern "C" fn rustls_client_config_fips( config: *const rustls_client_config, ) -> bool

Returns true if a rustls_connection created from the rustls_client_config will operate in FIPS mode.

This is different from rustls_crypto_provider_fips which is concerned only with cryptography, whereas this also covers TLS-level configuration that NIST recommends, as well as ECH HPKE suites if applicable.

Source

#[unsafe(no_mangle)]
pub extern "C" fn rustls_client_config_free( config: *const rustls_client_config, )

“Free” a rustls_client_config previously returned from rustls_client_config_builder_build.

Since rustls_client_config is actually an atomically reference-counted pointer, extant client connections may still hold an internal reference to the Rust object.

However, C code must consider this pointer unusable after “free“ing it.

Calling with NULL is fine. Must not be called twice with the same value.

Source

#[unsafe(no_mangle)]
pub extern "C" fn rustls_client_connection_new( config: *const rustls_client_config, server_name: *const c_char, conn_out: *mut *mut rustls_connection, ) -> rustls_result

Create a new client rustls_connection.

If this returns RUSTLS_RESULT_OK, the memory pointed to by conn_out is modified to point at a valid rustls_connection. The caller now owns the rustls_connection and must call rustls_connection_free when done with it.

Uses the rustls_client_config to determine ALPN protocol support. Prefer rustls_client_connection_new_alpn to customize this per-connection.

If this returns an error code, the memory pointed to by conn_out remains unchanged.

The server_name parameter can contain a hostname or an IP address in textual form (IPv4 or IPv6). This function will return an error if it cannot be parsed as one of those types.

Source

#[unsafe(no_mangle)]
pub extern "C" fn rustls_client_connection_new_alpn( config: *const rustls_client_config, server_name: *const c_char, alpn_protocols: *const rustls_slice_bytes<'_>, alpn_protocols_len: size_t, conn_out: *mut *mut rustls_connection, ) -> rustls_result

Create a new client rustls_connection with custom ALPN protocols.

Operates the same as rustls_client_connection_new, but allows specifying custom per-connection ALPN protocols instead of inheriting ALPN protocols from the rustls_clinet_config.

If this returns RUSTLS_RESULT_OK, the memory pointed to by conn_out is modified to point at a valid rustls_connection. The caller now owns the rustls_connection and must call rustls_connection_free when done with it.

If this returns an error code, the memory pointed to by conn_out remains unchanged.

The server_name parameter can contain a hostname or an IP address in textual form (IPv4 or IPv6). This function will return an error if it cannot be parsed as one of those types.

alpn_protocols must point to a buffer of rustls_slice_bytes (built by the caller) with alpn_protocols_len elements. Each element of the buffer must be a rustls_slice_bytes whose data field points to a single ALPN protocol ID. This function makes a copy of the data in alpn_protocols and does not retain any pointers, so the caller can free the pointed-to memory after calling.

Standard ALPN protocol IDs are defined at https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids.

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> 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, 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.