Skip to content
Durable Workflowrust

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
22    /// Disable TLS certificate and hostname verification for every request
23    /// this client makes, including worker polling and external payload
24    /// transfers. The default is `false` (verified).
25    ///
26    /// Any party on the network path can then read and change traffic,
27    /// including bearer tokens. Prefer
28    /// [`ClientBuilder::additional_root_certificates_pem`] for a private CA.
29    pub fn danger_accept_invalid_certs(mut self, accept: bool) -> Self {
30        self.danger_accept_invalid_certs = accept;
31        self
32    }
33}