osslsigncode 0.1.1

In-process Rust bindings for the vendored osslsigncode Authenticode implementation
use std::path::{Path, PathBuf};

/// Timestamp authority configuration.
#[derive(Clone, Debug)]
pub enum Timestamp {
    Authenticode(String),
    Rfc3161(String),
    Authority {
        certificates: PathBuf,
        key: PathBuf,
        unix_time: Option<i64>,
    },
}

impl Timestamp {
    /// Authenticode (`-t`) timestamp URL.
    pub fn authenticode(url: impl Into<String>) -> Self {
        Self::Authenticode(url.into())
    }

    /// RFC-3161 (`-ts`) timestamp URL.
    pub fn rfc3161(url: impl Into<String>) -> Self {
        Self::Rfc3161(url.into())
    }

    /// Local TSA certificate + key (and optional signing time).
    pub fn authority(
        certificates: impl AsRef<Path>,
        key: impl AsRef<Path>,
        unix_time: Option<i64>,
    ) -> Self {
        Self::Authority {
            certificates: certificates.as_ref().to_path_buf(),
            key: key.as_ref().to_path_buf(),
            unix_time,
        }
    }
}

/// Outbound HTTP settings for timestamping and CRL fetches.
#[derive(Clone, Debug)]
pub struct Network {
    pub proxy: Option<String>,
    pub verify_peer: bool,
    pub https_ca: Option<PathBuf>,
    pub https_crl: Option<PathBuf>,
}

impl Default for Network {
    fn default() -> Self {
        Self {
            proxy: None,
            verify_peer: true,
            https_ca: None,
            https_crl: None,
        }
    }
}

/// Trust store used by verification.
#[derive(Clone, Debug, Default)]
pub struct TrustAnchors {
    pub ca_file: Option<PathBuf>,
    pub crl_file: Option<PathBuf>,
    pub tsa_ca: Option<PathBuf>,
    pub tsa_crl: Option<PathBuf>,
}