@@ -128,6 +128,7 @@ pub struct ItemSearchOptions {
128128 keychains : Option < CFArray < SecKeychain > > ,
129129 #[ cfg( not( target_os = "macos" ) ) ]
130130 keychains : Option < CFArray < CFType > > ,
131+ ignore_legacy_keychains : bool , // defined everywhere, only consulted on macOS
131132 case_insensitive : Option < bool > ,
132133 class : Option < ItemClass > ,
133134 key_class : Option < KeyClass > ,
@@ -157,6 +158,12 @@ impl crate::ItemSearchOptionsInternals for ItemSearchOptions {
157158 self . keychains = Some ( CFArray :: from_CFTypes ( keychains) ) ;
158159 self
159160 }
161+
162+ #[ inline]
163+ fn ignore_legacy_keychains ( & mut self ) -> & mut Self {
164+ self . ignore_legacy_keychains = true ;
165+ self
166+ }
160167}
161168
162169impl ItemSearchOptions {
@@ -340,6 +347,15 @@ impl ItemSearchOptions {
340347 & keychains. as_CFType ( ) . to_void ( ) ,
341348 ) ;
342349 }
350+ else {
351+ if self . ignore_legacy_keychains {
352+ #[ cfg( all( target_os = "macos" , feature = "OSX_10_15" ) ) ]
353+ params. add (
354+ & kSecUseDataProtectionKeychain. to_void ( ) ,
355+ & CFBoolean :: true_value ( ) . to_void ( ) ,
356+ )
357+ }
358+ }
343359
344360 if let Some ( class) = self . class {
345361 params. add ( & kSecClass. to_void ( ) , & class. 0 . to_void ( ) ) ;
0 commit comments