Skip to content
This repository was archived by the owner on Jan 17, 2020. It is now read-only.
This repository was archived by the owner on Jan 17, 2020. It is now read-only.

invalid CA error catch with SSL #165

@Kxtreme

Description

@Kxtreme

when connecting to an SSL broker and set_ca(/invalid cert/), I can't catch the error
example:


        let reconnect_options = ReconnectOptions::Always(5);
        let mqtt_options = MqttOptions::new("rumqttRules".to_string(), "127.0.0.1".to_string(),8883u16)
            .set_keep_alive(30)
            .set_reconnect_opts(reconnect_options)
            .set_ca(include_bytes!("dummy_ca"))
            .set_clean_session(false);

if let Ok((mqtt_client, notifications)) = MqttClient::start(mqtt_options) {
     if let Ok(qos) = QoS::from_u8(0u8) {
           if let Err(error) = client.subscribe(topic, 0) {
               println!("ERROR: {:?}", error);
           }
     }
     for notification in notifications {
           //notification handling
     }
} else {
//Err handling
}

output:


thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:381
   6: rust_begin_unwind
             at src/libstd/panicking.rs:308
   7: core::panicking::panic_fmt
             at src/libcore/panicking.rs:85
   8: core::panicking::panic
             at src/libcore/panicking.rs:49
   9: core::option::Option<T>::unwrap
             at /rustc/a53f9df32fbb0b5f4382caaad8f1a46f36ea887c/src/libcore/macros.rs:12
  10: rumqtt::client::connection::Connection::handle_connection_error
             at /home/{username}/.cargo/git/checkouts/rumqtt-97ac1717aa98c207/f1d9885/src/client/connection.rs:278
  11: rumqtt::client::connection::Connection::connect_or_not
             at /home/{username}/.cargo/git/checkouts/rumqtt-97ac1717aa98c207/f1d9885/src/client/connection.rs:133
  12: rumqtt::client::connection::Connection::mqtt_eventloop
             at /home/{username}/.cargo/git/checkouts/rumqtt-97ac1717aa98c207/f1d9885/src/client/connection.rs:92
  13: rumqtt::client::connection::Connection::run::{{closure}}
             at /home/{username}/.cargo/git/checkouts/rumqtt-97ac1717aa98c207/f1d9885/src/client/connection.rs:60

I intended to capture this error so that I can inform the error cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions