summaryrefslogtreecommitdiff
path: root/vendor/security-framework/src/os/macos/mod.rs
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-10 13:11:11 -0600
committermo khan <mo@mokhan.ca>2025-07-10 13:11:11 -0600
commit01959b16a21b22b5df5f16569c2a8e8f92beecef (patch)
tree32afa5d747c5466345c59ec52161a7cba3d6d755 /vendor/security-framework/src/os/macos/mod.rs
parentff30574117a996df332e23d1fb6f65259b316b5b (diff)
chore: vendor dependencies
Diffstat (limited to 'vendor/security-framework/src/os/macos/mod.rs')
-rw-r--r--vendor/security-framework/src/os/macos/mod.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/security-framework/src/os/macos/mod.rs b/vendor/security-framework/src/os/macos/mod.rs
new file mode 100644
index 00000000..3e468fc3
--- /dev/null
+++ b/vendor/security-framework/src/os/macos/mod.rs
@@ -0,0 +1,52 @@
+//! OSX specific extensions.
+
+pub mod access;
+pub mod certificate;
+pub mod certificate_oids;
+pub mod code_signing;
+pub mod digest_transform;
+pub mod encrypt_transform;
+pub mod identity;
+pub mod import_export;
+pub mod item;
+pub mod key;
+pub mod keychain;
+pub mod keychain_item;
+pub mod passwords;
+pub mod secure_transport;
+pub mod transform;
+
+#[cfg(test)]
+pub mod test {
+ use crate::identity::SecIdentity;
+ use crate::item::{ItemClass, ItemSearchOptions, Reference, SearchResult};
+ use crate::os::macos::item::ItemSearchOptionsExt;
+ use crate::os::macos::keychain::SecKeychain;
+ use std::fs::File;
+ use std::io::prelude::*;
+ use std::path::Path;
+
+ #[must_use] pub fn identity(dir: &Path) -> SecIdentity {
+ // FIXME https://github.com/rust-lang/rust/issues/30018
+ let keychain = keychain(dir);
+ let mut items = p!(ItemSearchOptions::new()
+ .class(ItemClass::identity())
+ .keychains(&[keychain])
+ .search());
+ match items.pop().unwrap() {
+ SearchResult::Ref(Reference::Identity(identity)) => identity,
+ _ => panic!("expected identity"),
+ }
+ }
+
+ #[must_use] pub fn keychain(dir: &Path) -> SecKeychain {
+ let path = dir.join("server.keychain");
+ let mut file = p!(File::create(&path));
+ p!(file.write_all(include_bytes!("../../../test/server.keychain")));
+ drop(file);
+
+ let mut keychain = p!(SecKeychain::open(&path));
+ p!(keychain.unlock(Some("password123")));
+ keychain
+ }
+}