File tree 2 files changed +13
-1
lines changed
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"
21
21
lazy_static = " 1.4.0"
22
22
libc = " 0.2"
23
23
tempfile = " 3.1.0"
24
+ rand = " 0.8.4"
24
25
25
26
[target .'cfg(target_os = "windows")' .dependencies ]
26
27
schannel = " 0.1.17"
Original file line number Diff line number Diff line change 1
1
extern crate libc;
2
+ extern crate rand;
2
3
extern crate security_framework;
3
4
extern crate security_framework_sys;
4
5
extern crate tempfile;
@@ -91,7 +92,7 @@ impl Identity {
91
92
92
93
let dir = TempDir :: new ( ) . map_err ( |_| Error ( base:: Error :: from ( errSecIO) ) ) ?;
93
94
let keychain = keychain:: CreateOptions :: new ( )
94
- . password ( "password" )
95
+ . password ( & random_password ( ) )
95
96
. create ( dir. path ( ) . join ( "identity.keychain" ) ) ?;
96
97
97
98
let mut items = SecItems :: default ( ) ;
@@ -180,6 +181,16 @@ impl Identity {
180
181
}
181
182
}
182
183
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
+
183
194
#[ derive( Clone ) ]
184
195
pub struct Certificate ( SecCertificate ) ;
185
196
You can’t perform that action at this time.
0 commit comments