diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-06-11 18:35:00 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-06-11 18:35:00 +0200 |
| commit | 24ab81363b18f874c68690ae54ba8a27bd46acd3 (patch) | |
| tree | 4b888aba76db7759f85ff97d8772006a0ae8580c | |
| parent | 589560ae3a7ae7a46f4cdfe814393bda261fa53f (diff) | |
| download | mum-24ab81363b18f874c68690ae54ba8a27bd46acd3.tar.gz | |
servert cert reject is error
| -rw-r--r-- | mumctl/src/main.rs | 9 | ||||
| -rw-r--r-- | mumd/src/state.rs | 2 | ||||
| -rw-r--r-- | mumlib/src/command.rs | 1 | ||||
| -rw-r--r-- | mumlib/src/error.rs | 2 |
4 files changed, 8 insertions, 6 deletions
diff --git a/mumctl/src/main.rs b/mumctl/src/main.rs index 9de946e..bf1ffdc 100644 --- a/mumctl/src/main.rs +++ b/mumctl/src/main.rs @@ -272,15 +272,15 @@ fn match_opt() -> Result<(), Error> { username: username.to_string(), password: password.map(|x| x.to_string()), accept_invalid_cert: cli_accept_invalid_cert || config_accept_invalid_cert.unwrap_or(false), - })??; + })?; match response { - Some(CommandResponse::ServerConnect { welcome_message }) => { + Ok(Some(CommandResponse::ServerConnect { welcome_message })) => { println!("Connected to {}", host); if let Some(message) = welcome_message { println!("Welcome: {}", message); } } - Some(CommandResponse::ServerCertReject) => { + Err(mumlib::error::Error::ServerCertReject) => { error!("Connection rejected since the server supplied an invalid certificate."); if !specified_accept_invalid_cert { eprintln!("help: If you trust this server anyway, you can do any of the following to connect:"); @@ -289,7 +289,8 @@ fn match_opt() -> Result<(), Error> { eprintln!(" 3. Permantently trust all invalid certificates by setting accept_all_invalid_certs=true globally"); } } - other => unreachable!("Response should only be a ServerConnect or ServerCertReject. Got {:?}", other) + Ok(other) => unreachable!("Response should only be a ServerConnect or ServerCertReject. Got {:?}", other), + Err(e) => return Err(e.into()), } } Command::Disconnect => { diff --git a/mumd/src/state.rs b/mumd/src/state.rs index e0e3ccd..d93181a 100644 --- a/mumd/src/state.rs +++ b/mumd/src/state.rs @@ -575,7 +575,7 @@ pub fn handle_command( } }, TcpEvent::Disconnected(DisconnectedReason::InvalidTls) => |_| { - Box::new(iter::once(Ok(Some(CommandResponse::ServerCertReject)))) + Box::new(iter::once(Err(Error::ServerCertReject))) } ) } diff --git a/mumlib/src/command.rs b/mumlib/src/command.rs index 36bda72..351d7f6 100644 --- a/mumlib/src/command.rs +++ b/mumlib/src/command.rs @@ -53,7 +53,6 @@ pub enum CommandResponse { ServerConnect { welcome_message: Option<String>, }, - ServerCertReject, ServerStatus { version: u32, users: u32, diff --git a/mumlib/src/error.rs b/mumlib/src/error.rs index e88bd97..91c15e1 100644 --- a/mumlib/src/error.rs +++ b/mumlib/src/error.rs @@ -11,6 +11,7 @@ pub enum Error { InvalidServerAddr(String, u16), InvalidUsername(String), InvalidServerPassword, + ServerCertReject, } impl std::error::Error for Error {} @@ -26,6 +27,7 @@ impl fmt::Display for Error { } Error::InvalidUsername(username) => write!(f, "Invalid username: {}", username), Error::InvalidServerPassword => write!(f, "Invalid server password"), + Error::ServerCertReject => write!(f, "Invalid server certificate"), } } } |
