File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ security-framework-sys = "2.0.0"
2121lazy_static = " 1.4.0"
2222libc = " 0.2"
2323tempfile = " 3.1.0"
24+ rand = " 0.8.4"
2425
2526[target .'cfg(target_os = "windows")' .dependencies ]
2627schannel = " 0.1.17"
Original file line number Diff line number Diff line change 11extern crate libc;
2+ extern crate rand;
23extern crate security_framework;
34extern crate security_framework_sys;
45extern crate tempfile;
@@ -91,7 +92,7 @@ impl Identity {
9192
9293 let dir = TempDir :: new ( ) . map_err ( |_| Error ( base:: Error :: from ( errSecIO) ) ) ?;
9394 let keychain = keychain:: CreateOptions :: new ( )
94- . password ( "password" )
95+ . password ( & random_password ( ) )
9596 . create ( dir. path ( ) . join ( "identity.keychain" ) ) ?;
9697
9798 let mut items = SecItems :: default ( ) ;
@@ -180,6 +181,16 @@ impl Identity {
180181 }
181182}
182183
184+ fn random_password ( ) -> String {
185+ use self :: rand:: { distributions:: Alphanumeric , Rng } ;
186+
187+ self :: rand:: thread_rng ( )
188+ . sample_iter ( & Alphanumeric )
189+ . take ( 10 )
190+ . map ( char:: from)
191+ . collect ( )
192+ }
193+
183194#[ derive( Clone ) ]
184195pub struct Certificate ( SecCertificate ) ;
185196
You can’t perform that action at this time.
0 commit comments