pub struct Trust { /* private fields */ }full only.Expand description
Wraps SecTrustRef.
Implementations§
Source§impl Trust
impl Trust
Sourcepub fn new(certificate: &Certificate, policies: &[Policy]) -> Result<Self>
pub fn new(certificate: &Certificate, policies: &[Policy]) -> Result<Self>
Wraps the corresponding SecTrustRef operation.
Examples found in repository?
More examples
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 use security::async_api::AsyncTrust;
9 use security::{Certificate, Policy, Trust};
10
11 executor::block_on(async {
12 let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
13 let policy = Policy::basic_x509()?;
14 let mut trust = Trust::new(&certificate, &[policy])?;
15 trust.set_anchor_certificates(&[certificate])?;
16 trust.set_anchor_certificates_only(true)?;
17 trust.set_network_fetch_allowed(false)?;
18
19 AsyncTrust::new(&trust).evaluate()?.await?;
20 println!("chain_len={}", trust.certificate_chain()?.len());
21 Ok::<(), Box<dyn std::error::Error>>(())
22 })
23}Sourcepub fn from_certificates(
certificates: &[Certificate],
policies: &[Policy],
) -> Result<Self>
pub fn from_certificates( certificates: &[Certificate], policies: &[Policy], ) -> Result<Self>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn set_policies(&mut self, policies: &[Policy]) -> Result<()>
pub fn set_policies(&mut self, policies: &[Policy]) -> Result<()>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn set_anchor_certificates(
&mut self,
certificates: &[Certificate],
) -> Result<()>
pub fn set_anchor_certificates( &mut self, certificates: &[Certificate], ) -> Result<()>
Wraps the corresponding SecTrustRef operation.
Examples found in repository?
More examples
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 use security::async_api::AsyncTrust;
9 use security::{Certificate, Policy, Trust};
10
11 executor::block_on(async {
12 let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
13 let policy = Policy::basic_x509()?;
14 let mut trust = Trust::new(&certificate, &[policy])?;
15 trust.set_anchor_certificates(&[certificate])?;
16 trust.set_anchor_certificates_only(true)?;
17 trust.set_network_fetch_allowed(false)?;
18
19 AsyncTrust::new(&trust).evaluate()?.await?;
20 println!("chain_len={}", trust.certificate_chain()?.len());
21 Ok::<(), Box<dyn std::error::Error>>(())
22 })
23}Sourcepub fn custom_anchor_certificates(&self) -> Result<Value>
pub fn custom_anchor_certificates(&self) -> Result<Value>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn set_anchor_certificates_only(
&mut self,
only_anchor_certificates: bool,
) -> Result<()>
pub fn set_anchor_certificates_only( &mut self, only_anchor_certificates: bool, ) -> Result<()>
Wraps the corresponding SecTrustRef operation.
Examples found in repository?
More examples
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 use security::async_api::AsyncTrust;
9 use security::{Certificate, Policy, Trust};
10
11 executor::block_on(async {
12 let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
13 let policy = Policy::basic_x509()?;
14 let mut trust = Trust::new(&certificate, &[policy])?;
15 trust.set_anchor_certificates(&[certificate])?;
16 trust.set_anchor_certificates_only(true)?;
17 trust.set_network_fetch_allowed(false)?;
18
19 AsyncTrust::new(&trust).evaluate()?.await?;
20 println!("chain_len={}", trust.certificate_chain()?.len());
21 Ok::<(), Box<dyn std::error::Error>>(())
22 })
23}Sourcepub fn set_network_fetch_allowed(&mut self, allowed: bool) -> Result<()>
pub fn set_network_fetch_allowed(&mut self, allowed: bool) -> Result<()>
Wraps the corresponding SecTrustRef operation.
Examples found in repository?
More examples
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 use security::async_api::AsyncTrust;
9 use security::{Certificate, Policy, Trust};
10
11 executor::block_on(async {
12 let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
13 let policy = Policy::basic_x509()?;
14 let mut trust = Trust::new(&certificate, &[policy])?;
15 trust.set_anchor_certificates(&[certificate])?;
16 trust.set_anchor_certificates_only(true)?;
17 trust.set_network_fetch_allowed(false)?;
18
19 AsyncTrust::new(&trust).evaluate()?.await?;
20 println!("chain_len={}", trust.certificate_chain()?.len());
21 Ok::<(), Box<dyn std::error::Error>>(())
22 })
23}Sourcepub fn network_fetch_allowed(&self) -> Result<bool>
pub fn network_fetch_allowed(&self) -> Result<bool>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn set_verify_date(&mut self, verify_date: SystemTime) -> Result<()>
pub fn set_verify_date(&mut self, verify_date: SystemTime) -> Result<()>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn verify_time(&self) -> Result<Option<SystemTime>>
pub fn verify_time(&self) -> Result<Option<SystemTime>>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn evaluate_async(&self) -> Result<()>
pub fn evaluate_async(&self) -> Result<()>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn trust_result_type(&self) -> Result<TrustResultType>
pub fn trust_result_type(&self) -> Result<TrustResultType>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn certificate_count(&self) -> usize
pub fn certificate_count(&self) -> usize
Wraps the corresponding SecTrustRef operation.
Sourcepub fn certificate_chain(&self) -> Result<Vec<Certificate>>
pub fn certificate_chain(&self) -> Result<Vec<Certificate>>
Wraps the corresponding SecTrustRef operation.
Examples found in repository?
More examples
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 use security::async_api::AsyncTrust;
9 use security::{Certificate, Policy, Trust};
10
11 executor::block_on(async {
12 let certificate = Certificate::from_der(&support::fixture("test-cert.der"))?;
13 let policy = Policy::basic_x509()?;
14 let mut trust = Trust::new(&certificate, &[policy])?;
15 trust.set_anchor_certificates(&[certificate])?;
16 trust.set_anchor_certificates_only(true)?;
17 trust.set_network_fetch_allowed(false)?;
18
19 AsyncTrust::new(&trust).evaluate()?.await?;
20 println!("chain_len={}", trust.certificate_chain()?.len());
21 Ok::<(), Box<dyn std::error::Error>>(())
22 })
23}Sourcepub fn exceptions(&self) -> Result<Option<Vec<u8>>>
pub fn exceptions(&self) -> Result<Option<Vec<u8>>>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn set_exceptions(&mut self, exceptions: Option<&[u8]>) -> Result<bool>
pub fn set_exceptions(&mut self, exceptions: Option<&[u8]>) -> Result<bool>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn set_ocsp_responses(&mut self, responses: &[Vec<u8>]) -> Result<()>
pub fn set_ocsp_responses(&mut self, responses: &[Vec<u8>]) -> Result<()>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn set_signed_certificate_timestamps(
&mut self,
timestamps: &[Vec<u8>],
) -> Result<()>
pub fn set_signed_certificate_timestamps( &mut self, timestamps: &[Vec<u8>], ) -> Result<()>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn set_options(&mut self, options: TrustOptions) -> Result<()>
pub fn set_options(&mut self, options: TrustOptions) -> Result<()>
Wraps the corresponding SecTrustRef operation.
Sourcepub fn system_anchor_certificates() -> Result<Value>
pub fn system_anchor_certificates() -> Result<Value>
Wraps the corresponding SecTrustRef operation.