Skip to main content

durable_workflow/
tls.rs

1use crate::{ClientBuilder, Error, Result};
2
3impl ClientBuilder {
4    /// Trust additional PEM root certificates, preserving the bundled public roots.
5    ///
6    /// Accepts one or more `CERTIFICATE` entries, and can be called repeatedly.
7    /// Invalid PEM and bundles without certificates are rejected. Certificate
8    /// chains and hostnames are still verified for every request, including
9    /// worker polling and external payload transfers.
10    pub fn additional_root_certificates_pem(mut self, pem: impl AsRef<[u8]>) -> Result<Self> {
11        let certificates = reqwest::Certificate::from_pem_bundle(pem.as_ref())
12            .map_err(|error| Error::InvalidRootCertificates(error.to_string()))?;
13        if certificates.is_empty() {
14            return Err(Error::InvalidRootCertificates(
15                "PEM bundle must contain at least one CERTIFICATE entry".into(),
16            ));
17        }
18        self.additional_root_certificates.extend(certificates);
19        Ok(self)
20    }
21}