File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ pub fn is_sensitive_key(key_name: &str) -> bool {
6565
6666pub fn find_private_key_from_home ( public_key_hex : & str ) -> Option < String > {
6767 if let Ok ( key_store) = DotenvxKeyStore :: load_global ( ) {
68- key_store. find_private_key ( public_key_hex) ;
68+ return key_store. find_private_key ( public_key_hex) ;
6969 }
7070 None
7171}
@@ -181,7 +181,7 @@ pub fn get_private_key_for_file(env_file: &str) -> Result<String, Box<dyn std::e
181181 if !public_key. is_empty ( )
182182 && let Some ( private_key) = find_private_key_from_home ( & public_key)
183183 {
184- return Ok ( private_key) ;
184+ return Ok ( trim_private_key ( private_key) ) ;
185185 }
186186 let profile_name = get_profile_name_from_file ( env_file) ;
187187 get_private_key ( & profile_name)
@@ -862,4 +862,12 @@ mod tests {
862862 let public_key = get_public_key_from_text_file ( file_path) . unwrap ( ) ;
863863 println ! ( "public key: {public_key}" ) ;
864864 }
865+
866+ #[ test]
867+ fn tes_find_private_key ( ) {
868+ let private_key = find_private_key_from_home (
869+ "028d59ff8bc98e7bfb7d7a0a6f511a653907cd3135db9ead01f293bcb7beb3ecd3" ,
870+ ) ;
871+ println ! ( "private key: {private_key:?}" )
872+ }
865873}
You can’t perform that action at this time.
0 commit comments