Skip to main content

Policy

Struct Policy 

Source
pub struct Policy { /* private fields */ }

Implementations§

Source§

impl Policy

Source

pub fn basic_x509() -> Result<Self>

Examples found in repository?
examples/05_trust_evaluate.rs (line 8)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7    let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
8    let policy = Policy::basic_x509()?;
9    let mut trust = Trust::new(&certificate, &[policy])?;
10    trust.set_anchor_certificates(&[certificate])?;
11    trust.set_anchor_certificates_only(true)?;
12    trust.set_network_fetch_allowed(false)?;
13    trust.evaluate()?;
14    println!("chain_len={}", trust.certificate_chain()?.len());
15    Ok(())
16}
More examples
Hide additional examples
examples/04_policy_properties.rs (line 4)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let basic = Policy::basic_x509()?;
5    let ssl = Policy::ssl(true, Some("localhost"))?;
6    let custom_ssl = Policy::with_properties(
7        PolicyIdentifier::AppleSsl,
8        &PolicyProperties {
9            name: Some(PolicyName::from("localhost")),
10            client: Some(false),
11            ..PolicyProperties::default()
12        },
13    )?;
14    let revocation = Policy::revocation(0)?;
15    println!(
16        "basic={:?} ssl={:?} custom_ssl={:?} revocation={:?}",
17        basic.properties()?,
18        ssl.properties()?,
19        custom_ssl.properties()?,
20        revocation.properties()?
21    );
22    Ok(())
23}
Source

pub fn ssl(server: bool, hostname: Option<&str>) -> Result<Self>

Examples found in repository?
examples/04_policy_properties.rs (line 5)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let basic = Policy::basic_x509()?;
5    let ssl = Policy::ssl(true, Some("localhost"))?;
6    let custom_ssl = Policy::with_properties(
7        PolicyIdentifier::AppleSsl,
8        &PolicyProperties {
9            name: Some(PolicyName::from("localhost")),
10            client: Some(false),
11            ..PolicyProperties::default()
12        },
13    )?;
14    let revocation = Policy::revocation(0)?;
15    println!(
16        "basic={:?} ssl={:?} custom_ssl={:?} revocation={:?}",
17        basic.properties()?,
18        ssl.properties()?,
19        custom_ssl.properties()?,
20        revocation.properties()?
21    );
22    Ok(())
23}
Source

pub fn revocation(flags: RevocationFlags) -> Result<Self>

Examples found in repository?
examples/04_policy_properties.rs (line 14)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let basic = Policy::basic_x509()?;
5    let ssl = Policy::ssl(true, Some("localhost"))?;
6    let custom_ssl = Policy::with_properties(
7        PolicyIdentifier::AppleSsl,
8        &PolicyProperties {
9            name: Some(PolicyName::from("localhost")),
10            client: Some(false),
11            ..PolicyProperties::default()
12        },
13    )?;
14    let revocation = Policy::revocation(0)?;
15    println!(
16        "basic={:?} ssl={:?} custom_ssl={:?} revocation={:?}",
17        basic.properties()?,
18        ssl.properties()?,
19        custom_ssl.properties()?,
20        revocation.properties()?
21    );
22    Ok(())
23}
Source

pub fn with_properties( identifier: PolicyIdentifier, properties: &PolicyProperties, ) -> Result<Self>

Examples found in repository?
examples/04_policy_properties.rs (lines 6-13)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let basic = Policy::basic_x509()?;
5    let ssl = Policy::ssl(true, Some("localhost"))?;
6    let custom_ssl = Policy::with_properties(
7        PolicyIdentifier::AppleSsl,
8        &PolicyProperties {
9            name: Some(PolicyName::from("localhost")),
10            client: Some(false),
11            ..PolicyProperties::default()
12        },
13    )?;
14    let revocation = Policy::revocation(0)?;
15    println!(
16        "basic={:?} ssl={:?} custom_ssl={:?} revocation={:?}",
17        basic.properties()?,
18        ssl.properties()?,
19        custom_ssl.properties()?,
20        revocation.properties()?
21    );
22    Ok(())
23}
Source

pub fn properties(&self) -> Result<Value>

Examples found in repository?
examples/04_policy_properties.rs (line 17)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let basic = Policy::basic_x509()?;
5    let ssl = Policy::ssl(true, Some("localhost"))?;
6    let custom_ssl = Policy::with_properties(
7        PolicyIdentifier::AppleSsl,
8        &PolicyProperties {
9            name: Some(PolicyName::from("localhost")),
10            client: Some(false),
11            ..PolicyProperties::default()
12        },
13    )?;
14    let revocation = Policy::revocation(0)?;
15    println!(
16        "basic={:?} ssl={:?} custom_ssl={:?} revocation={:?}",
17        basic.properties()?,
18        ssl.properties()?,
19        custom_ssl.properties()?,
20        revocation.properties()?
21    );
22    Ok(())
23}

Trait Implementations§

Source§

impl Debug for Policy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.