spin_factor_outbound_networking/
runtime_config.rs

1#[cfg(feature = "spin-cli")]
2pub mod spin;
3
4pub use rustls_pki_types::{CertificateDer, PrivateKeyDer};
5
6/// Runtime configuration for outbound networking.
7#[derive(Debug, Default)]
8pub struct RuntimeConfig {
9    /// Blocked IP networks
10    pub blocked_ip_networks: Vec<ip_network::IpNetwork>,
11    /// If true, non-globally-routable networks are blocked
12    pub block_private_networks: bool,
13    /// TLS client configs
14    pub client_tls_configs: Vec<ClientTlsRuntimeConfig>,
15}
16
17/// TLS configuration for one or more component(s) and host(s).
18#[derive(Debug)]
19pub struct ClientTlsRuntimeConfig {
20    /// The component(s) this configuration applies to.
21    pub components: Vec<String>,
22    /// The host(s) this configuration applies to.
23    pub hosts: Vec<String>,
24    /// A set of CA certs that should be considered valid roots.
25    pub root_certificates: Vec<CertificateDer<'static>>,
26    /// If true, the "standard" CA certs defined by `webpki-roots` crate will be
27    /// considered valid roots in addition to `root_certificates`.
28    pub use_webpki_roots: bool,
29    /// A certificate and private key to be used as the client certificate for
30    /// "mutual TLS" (mTLS).
31    pub client_cert: Option<ClientCertRuntimeConfig>,
32}
33
34impl Default for ClientTlsRuntimeConfig {
35    fn default() -> Self {
36        Self {
37            components: vec![],
38            hosts: vec![],
39            root_certificates: vec![],
40            // Use webpki roots by default
41            use_webpki_roots: true,
42            client_cert: None,
43        }
44    }
45}
46
47#[derive(Debug)]
48pub struct ClientCertRuntimeConfig {
49    pub cert_chain: Vec<CertificateDer<'static>>,
50    pub key_der: PrivateKeyDer<'static>,
51}