consumption works fine locally when using amqp
let conn = Connection::connect(&addr, ConnectionProperties::default())
.await
.expect("connects to rabbitmq ok");
but when deploying to test env I need to use amqps and it’s getting an invalid cert error so I tried to accept invalid certs
Code I’m using to connect is based on https://github.com/amqp-rs/lapin/blob/main/examples/custom_tls_connection.rs
let uri = addr.parse::<AMQPUri>().unwrap();
let connect = move |uri: &AMQPUri| {
uri.connect().and_then(|stream| {
let mut tls_builder = NativeTlsConnector::builder();
tls_builder.danger_accept_invalid_certs(true);
stream.into_native_tls(
&tls_builder.build().expect("TLS configuration failed"),
&uri.authority.host,
)
})
};
let conn = Connection::connector(uri, Box::new(connect), ConnectionProperties::default())
.await
.expect("connects to rabbitmq ok");
excepton I’m getting is
thread 'main' panicked at src/event_consumer.rs:61:10:
connects to rabbitmq ok: IOError(Custom { kind: InvalidData, error: InvalidCertificate(UnknownIssuer) })
stack backtrace:
0: rust_begin_unwind
at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
2: core::result::unwrap_failed
at ./rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/result.rs:1649:5
3: ord::event_consumer::EventConsumer::run::{{closure}}
4: tokio::runtime::runtime::Runtime::block_on
5: ord::arguments::Arguments::run
6: ord::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Similar issue seems to be https://github.com/amqp-rs/lapin/issues/396 but RustlsConnector
does not have a way to accept invalid certs from what I can tell.
Any ideas how to accept invalid certs using lapin?
New contributor