Struct SecPolicy

Source
#[repr(C)]
pub struct SecPolicy { /* private fields */ }
Available on crate feature SecBase only.
Expand description

CFType representing a X.509 certificate trust policy. See SecPolicy.h for details.

See also Apple’s documentation

Implementations§

Source§

impl SecPolicy

Source

pub unsafe fn properties(self: &SecPolicy) -> Option<CFRetained<CFDictionary>>

Available on crate feature SecPolicy only.

Returns a dictionary of this policy’s properties.

Parameter policyRef: A policy reference.

Returns: A properties dictionary. See “Policy Value Constants” for a list of currently defined property keys. It is the caller’s responsibility to CFRelease this reference when it is no longer needed.

Returns: A result code. See “Security Error Codes” (SecBase.h).

This function returns the properties for a policy, as set by the policy’s construction function or by a prior call to SecPolicySetProperties.

Source

pub unsafe fn new_basic_x509() -> CFRetained<SecPolicy>

Available on crate feature SecPolicy only.

Returns a policy object for the default X.509 policy.

Returns: A policy object. The caller is responsible for calling CFRelease on this when it is no longer needed.

Source

pub unsafe fn new_ssl( server: bool, hostname: Option<&CFString>, ) -> CFRetained<SecPolicy>

Available on crate feature SecPolicy only.

Returns a policy object for evaluating SSL certificate chains.

Parameter server: Passing true for this parameter creates a policy for SSL server certificates.

Parameter hostname: (Optional) If present, the policy will require the specified hostname to match the hostname in the leaf certificate.

Returns: A policy object. The caller is responsible for calling CFRelease on this when it is no longer needed.

Source§

impl SecPolicy

Source

pub unsafe fn new_revocation( revocation_flags: CFOptionFlags, ) -> Option<CFRetained<SecPolicy>>

Available on crate feature SecPolicy only.

Returns a policy object for checking revocation of certificates.

Returns: A policy object. The caller is responsible for calling CFRelease on this when it is no longer needed.

Parameter revocationFlags: Flags to specify revocation checking options.

Use this function to create a revocation policy with behavior specified by revocationFlags. See the “Revocation Policy Constants” section for a description of these flags. Note: it is usually not necessary to create a revocation policy yourself unless you wish to override default system behavior (e.g. to force a particular method, or to disable revocation checking entirely.)

Source

pub unsafe fn with_properties( policy_identifier: &CFType, properties: Option<&CFDictionary>, ) -> Option<CFRetained<SecPolicy>>

Available on crate feature SecPolicy only.

Returns a policy object based on an object identifier for the policy type. See the “Policy Constants” section for a list of defined policy object identifiers.

Parameter policyIdentifier: The identifier for the desired policy type.

Parameter properties: (Optional) A properties dictionary. See “Policy Value Constants” for a list of currently defined property keys.

Returns: The returned policy reference, or NULL if the policy could not be created.

Source§

impl SecPolicy

Source

pub unsafe fn with_oid(policy_oid: &CFType) -> Option<CFRetained<SecPolicy>>

👎Deprecated
Available on crate feature SecPolicy only.

Returns a policy object based on an object identifier for the policy type. See the “Policy Constants” section for a list of defined policy object identifiers.

Parameter policyOID: The OID of the desired policy.

Returns: The returned policy reference, or NULL if the policy could not be created.

This function is deprecated in Mac OS X 10.9 and later; use SecPolicyCreateWithProperties (or a more specific policy creation function) instead.

Source

pub unsafe fn oid(self: &SecPolicy, oid: NonNull<SecAsn1Oid>) -> i32

👎Deprecated
Available on crate features SecPolicy and SecAsn1Types only.

Returns a policy’s object identifier.

Parameter policyRef: A policy reference.

Parameter oid: On return, a pointer to the policy’s object identifier.

Returns: A result code. See “Security Error Codes” (SecBase.h).

This function is deprecated in Mac OS X 10.7 and later; use SecPolicyCopyProperties instead.

Source

pub unsafe fn value(self: &SecPolicy, value: NonNull<SecAsn1Item>) -> i32

👎Deprecated
Available on crate features SecPolicy and SecAsn1Types only.

Returns a policy’s value.

Parameter policyRef: A policy reference.

Parameter value: On return, a pointer to the policy’s value.

Returns: A result code. See “Security Error Codes” (SecBase.h).

This function is deprecated in Mac OS X 10.7 and later; use SecPolicyCopyProperties instead.

Source

pub unsafe fn set_value(self: &SecPolicy, value: NonNull<SecAsn1Item>) -> i32

👎Deprecated
Available on crate features SecPolicy and SecAsn1Types only.

Sets a policy’s value.

Parameter policyRef: A policy reference.

Parameter value: The value to be set into the policy object, replacing any previous value.

Returns: A result code. See “Security Error Codes” (SecBase.h).

This function is deprecated in Mac OS X 10.7 and later. Policy instances should be considered read-only; in cases where your code would consider changing properties of a policy, it should instead create a new policy instance with the desired properties.

Source

pub unsafe fn set_properties(self: &SecPolicy, properties: &CFDictionary) -> i32

👎Deprecated
Available on crate feature SecPolicy only.

Sets a policy’s properties.

Parameter policyRef: A policy reference.

Parameter properties: A properties dictionary. See “Policy Value Constants” for a list of currently defined property keys. This dictionary replaces the policy’s existing properties, if any. Note that the policy OID (specified by kSecPolicyOid) is a read-only property of the policy and cannot be set.

Returns: A result code. See “Security Error Codes” (SecBase.h).

This function is deprecated in Mac OS X 10.9 and later. Policy instances should be considered read-only; in cases where your code would consider changing properties of a policy, it should instead create a new policy instance with the desired properties.

Source

pub unsafe fn tp_handle( self: &SecPolicy, tp_handle: NonNull<CSSM_TP_HANDLE>, ) -> i32

👎Deprecated
Available on crate features SecPolicy and cssmconfig and cssmtype only.

Returns the CSSM trust policy handle for the given policy.

Parameter policyRef: A policy reference.

Parameter tpHandle: On return, a pointer to a value of type CSSM_TP_HANDLE.

Returns: A result code. See “Security Error Codes” (SecBase.h).

This function is deprecated in Mac OS X 10.7 and later.

Methods from Deref<Target = CFType>§

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: ConcreteType,

Available on crate feature SecCustomTransform only.

Attempt to downcast the type to that of type T.

This is the reference-variant. Use CFRetained::downcast if you want to convert a retained type. See also ConcreteType for more details on which types support being converted to.

Source

pub fn retain_count(&self) -> usize

Available on crate feature SecCustomTransform only.

Get the reference count of the object.

This function may be useful for debugging. You normally do not use this function otherwise.

Beware that some things (like CFNumbers, small CFStrings etc.) may not have a normal retain count for optimization purposes, and can return usize::MAX in that case.

Trait Implementations§

Source§

impl AsRef<AnyObject> for SecPolicy

Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFType> for SecPolicy

Source§

fn as_ref(&self) -> &CFType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<SecPolicy> for SecPolicy

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for SecPolicy

Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for SecPolicy

Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for SecPolicy

Available on crate feature SecPolicy only.
Source§

fn type_id() -> CFTypeID

Returns the type identifier of SecPolicy instances.

Returns: The CFTypeID of SecPolicy instances.

Source§

impl Debug for SecPolicy

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deref for SecPolicy

Source§

type Target = CFType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for SecPolicy

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for SecPolicy

Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl PartialEq for SecPolicy

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for SecPolicy

Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Type for SecPolicy

Source§

fn retain(&self) -> CFRetained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

fn as_concrete_TypeRef(&self) -> &Self

👎Deprecated: this is redundant
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::retain
Helper for easier transition from the core-foundation crate. Read more
Source§

fn as_CFTypeRef(&self) -> &CFType
where Self: AsRef<CFType>,

👎Deprecated: this is redundant (CF types deref to CFType)
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::from_raw
Helper for easier transition from the core-foundation crate. Read more
Source§

impl Eq for SecPolicy

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Source§

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