Updating api documentation for s2n_cert_chain_get_cert
@@ -454,9 +454,17 @@ extern int s2n_cert_chain_get_length(const struct s2n_cert_chain_and_key *chain_
* 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.
- * @param cert_length This return value represents the length of the s2n certificate chain `chain_and_key`.
*/
S2N_API
extern int s2n_cert_chain_get_cert(const struct s2n_cert_chain_and_key *chain_and_key, struct s2n_cert **out_cert, const uint32_t cert_idx);
