Skip to content

Commit

Permalink
SecCertificateAddToKeychain and SecTrustSettingsSetTrustSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
emanuele-em authored and kornelski committed May 12, 2023
1 parent 1976cd6 commit 4261ffd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions security-framework-sys/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use core_foundation_sys::string::CFStringRef;

use crate::base::SecCertificateRef;
use crate::base::SecKeyRef;
use crate::base::SecKeychainRef;

extern "C" {
#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -40,6 +41,10 @@ extern "C" {
allocator: CFAllocatorRef,
data: CFDataRef,
) -> SecCertificateRef;
pub fn SecCertificateAddToKeychain(
certificate: SecCertificateRef,
keychain: SecKeychainRef,
) -> OSStatus;
pub fn SecCertificateCopyData(certificate: SecCertificateRef) -> CFDataRef;
pub fn SecCertificateCopySubjectSummary(certificate: SecCertificateRef) -> CFStringRef;
pub fn SecCertificateCopyCommonName(
Expand Down
6 changes: 6 additions & 0 deletions security-framework-sys/src/trust_settings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::base::SecCertificateRef;
use core_foundation_sys::array::CFArrayRef;
use core_foundation_sys::base::CFTypeRef;
use core_foundation_sys::base::OSStatus;

pub type SecTrustSettingsDomain = u32;
Expand All @@ -26,4 +27,9 @@ extern "C" {
domain: SecTrustSettingsDomain,
trustSettings: *mut CFArrayRef,
) -> OSStatus;
pub fn SecTrustSettingsSetTrustSettings(
certificateRef: SecCertificateRef,
domain: SecTrustSettingsDomain,
trustSettingsDictOrArray: CFTypeRef,
) -> OSStatus;
}
7 changes: 4 additions & 3 deletions security-framework/src/trust_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ use crate::cvt;

/// Which set of trust settings to query
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(u32)]
pub enum Domain {
/// Per-user trust settings
User,
User = kSecTrustSettingsDomainUser,
/// Locally administered, system-wide trust settings
Admin,
Admin = kSecTrustSettingsDomainAdmin,
/// System trust settings
System,
System = kSecTrustSettingsDomainSystem,
}

impl From<Domain> for SecTrustSettingsDomain {
Expand Down

0 comments on commit 4261ffd

Please sign in to comment.