Function s2n_quic_tls::ffi::s2n_cert_chain_get_cert
source · pub unsafe extern "C" fn s2n_cert_chain_get_cert(
chain_and_key: *const s2n_cert_chain_and_key,
out_cert: *mut *mut s2n_cert,
cert_idx: u32
) -> i32
Expand description
Returns the certificate out_cert
present at the index cert_idx
of the certificate chain chain_and_key
.
Note that the index of the leaf certificate is zero. If the certificate chain chain_and_key
is NULL or the
certificate index value is not in the acceptable range for the input certificate chain, an error is returned.
§Safety
There is no memory allocation required for out_cert
buffer prior to calling the s2n_cert_chain_get_cert
API.
The out_cert
will contain the pointer to the s2n_cert initialized within the input s2n_cert_chain_and_key chain_and_key
.
The pointer to the output s2n certificate out_cert
is valid until chain_and_key
is freed up.
If a caller wishes to persist the out_cert
beyond the lifetime of chain_and_key
, the contents would need to be
copied prior to freeing chain_and_key
.
@param chain_and_key A pointer to the s2n_cert_chain_and_key object being read.
@param out_cert A pointer to the output s2n_cert out_cert
present at the index cert_idx
of the certificate chain chain_and_key
.
@param cert_idx The certificate index for the requested certificate within the s2n certificate chain.