@@ -659,7 +659,12 @@ impl Session {
659659 /// Public key or certificate authentication
660660 /// If a companion certificate file exists (e.g., id_ed25519-cert.pub), uses certificate auth
661661 /// Returns AuthResult containing any warnings from the authentication process
662- pub async fn key_auth ( & mut self , username : & str , host : & str , key_path : PathBuf ) -> Result < AuthResult > {
662+ pub async fn key_auth (
663+ & mut self ,
664+ username : & str ,
665+ host : & str ,
666+ key_path : PathBuf ,
667+ ) -> Result < AuthResult > {
663668 // Check if there's a companion certificate for this key
664669 if let Some ( cert_path) = Self :: find_certificate_for_key ( & key_path) . await {
665670 return self . cert_auth ( username, host, key_path, cert_path) . await ;
@@ -739,11 +744,16 @@ impl Session {
739744 } ;
740745
741746 // Read certificate file content
742- let cert_content = std:: fs:: read_to_string ( & cert_path)
743- . map_err ( |e| eyre:: eyre!( "Failed to read certificate file {}: {e}" , cert_path. display( ) ) ) ?;
747+ let cert_content = std:: fs:: read_to_string ( & cert_path) . map_err ( |e| {
748+ eyre:: eyre!(
749+ "Failed to read certificate file {}: {e}" ,
750+ cert_path. display( )
751+ )
752+ } ) ?;
744753
745754 let cert_source = cert_path. display ( ) . to_string ( ) ;
746- self . cert_auth_impl ( username, host, key_pair, & cert_content, & cert_source) . await
755+ self . cert_auth_impl ( username, host, key_pair, & cert_content, & cert_source)
756+ . await
747757 }
748758
749759 /// Attempt public key authentication with an already-loaded key.
@@ -784,7 +794,9 @@ impl Session {
784794 . map_err ( |e| eyre:: eyre!( "Failed to write temp certificate: {e}" ) ) ?;
785795
786796 // Guard ensures temp file is cleaned up on any exit path
787- let _temp_guard = TempFileGuard { path : temp_cert_path. clone ( ) } ;
797+ let _temp_guard = TempFileGuard {
798+ path : temp_cert_path. clone ( ) ,
799+ } ;
788800
789801 // Load the certificate
790802 let cert = match russh:: keys:: load_openssh_certificate ( & temp_cert_path) {
@@ -886,10 +898,16 @@ impl Session {
886898
887899 match auth_res {
888900 russh:: client:: AuthResult :: Success => {
889- tracing:: info!( "✓ Certificate authentication successful with {}" , cert_source) ;
901+ tracing:: info!(
902+ "✓ Certificate authentication successful with {}" ,
903+ cert_source
904+ ) ;
890905 Ok ( AuthResult :: default ( ) )
891906 }
892- russh:: client:: AuthResult :: Failure { remaining_methods, partial_success } => {
907+ russh:: client:: AuthResult :: Failure {
908+ remaining_methods,
909+ partial_success,
910+ } => {
893911 tracing:: warn!(
894912 "Server rejected certificate {} (remaining methods: {:?}, partial: {})" ,
895913 cert_source,
@@ -1014,7 +1032,10 @@ impl Session {
10141032 identity_files. len( )
10151033 ) ;
10161034 for identity_file in & identity_files {
1017- if let Ok ( auth_result) = self . key_auth ( username, & hostname, identity_file. clone ( ) ) . await {
1035+ if let Ok ( auth_result) = self
1036+ . key_auth ( username, & hostname, identity_file. clone ( ) )
1037+ . await
1038+ {
10181039 return Ok ( auth_result) ;
10191040 }
10201041 }
@@ -1121,7 +1142,12 @@ impl Session {
11211142 tracing:: info!( "Step 0: Trying block-provided pasted key" ) ;
11221143 // For pasted key content with explicit certificate, use cert_auth_from_content
11231144 match self
1124- . key_auth_from_content_with_cert ( username, & hostname, content, certificate_config)
1145+ . key_auth_from_content_with_cert (
1146+ username,
1147+ & hostname,
1148+ content,
1149+ certificate_config,
1150+ )
11251151 . await
11261152 {
11271153 Ok ( auth_result) => {
@@ -1139,7 +1165,12 @@ impl Session {
11391165 SshIdentityKeyConfig :: Path { path } => {
11401166 tracing:: info!( "Step 0: Trying block-provided key path: {}" , path) ;
11411167 match self
1142- . key_auth_with_cert_config ( username, & hostname, PathBuf :: from ( path) , certificate_config)
1168+ . key_auth_with_cert_config (
1169+ username,
1170+ & hostname,
1171+ PathBuf :: from ( path) ,
1172+ certificate_config,
1173+ )
11431174 . await
11441175 {
11451176 Ok ( auth_result) => {
@@ -1238,11 +1269,16 @@ impl Session {
12381269 cert_path : PathBuf ,
12391270 ) -> Result < AuthResult > {
12401271 // Read certificate file content and delegate to impl
1241- let cert_content = std:: fs:: read_to_string ( & cert_path)
1242- . map_err ( |e| eyre:: eyre!( "Failed to read certificate file {}: {e}" , cert_path. display( ) ) ) ?;
1272+ let cert_content = std:: fs:: read_to_string ( & cert_path) . map_err ( |e| {
1273+ eyre:: eyre!(
1274+ "Failed to read certificate file {}: {e}" ,
1275+ cert_path. display( )
1276+ )
1277+ } ) ?;
12431278
12441279 let cert_source = cert_path. display ( ) . to_string ( ) ;
1245- self . cert_auth_impl ( username, host, key_pair, & cert_content, & cert_source) . await
1280+ self . cert_auth_impl ( username, host, key_pair, & cert_content, & cert_source)
1281+ . await
12461282 }
12471283
12481284 /// Certificate auth with an already-loaded key pair and pasted certificate content
@@ -1254,7 +1290,8 @@ impl Session {
12541290 cert_content : & str ,
12551291 ) -> Result < AuthResult > {
12561292 // Delegate directly to impl with pasted content indicator
1257- self . cert_auth_impl ( username, host, key_pair, cert_content, "(pasted content)" ) . await
1293+ self . cert_auth_impl ( username, host, key_pair, cert_content, "(pasted content)" )
1294+ . await
12581295 }
12591296
12601297 pub async fn disconnect ( & self ) -> Result < ( ) > {
0 commit comments