Secure Rust client and openssl/native_tls crates

I’m trying to make a connection to an secure cocroach cluster using Rust. So I try to follow the example in the article here: https://www.bookstack.cn/read/CockroachDB/d34f4af2f9885ead.md?wd=Rust
Which starts off:

use postgres::{Connection, TlsMode};`
use postgres::tls::openssl::OpenSsl;`
use postgres::tls::openssl::openssl::ssl::{SslConnectorBuilder, SslMethod};`
use postgres::tls::openssl::openssl::x509::X509_FILETYPE_PEM;`

Sadly that fails to even start to build with " "failed to resolve: could not find openssl in tls

Then I tried the examples here: https://docs.rs/postgres-openssl/0.2.0-rc.1/postgres_openssl/ and here: https://docs.rs/postgres-native-tls/0.2.0-rc.1/postgres_native_tls/ Each of which ends up with similar unresolved messages.

My Cargo.toml file currently contains this:

[dependencies]
openssl = "*"
postgres = "0.15.2"
postgres-openssl = "*"
postgres-native-tls = "*"
native-tls = "*"

After chasing documentation and examples around for hours and trying this and that I have totally failed to even get off the ground with this.

Does anyone have an example of working Cargo.toml and use clauses to get me started?

Hi @heater,

We’re taking a look at our code examples on https://www.cockroachlabs.com/docs//v19.1/build-a-rust-app-with-cockroachdb.html.

Any chance this was created by you?

Thanks,
Matt

Indeed that was me.

I just got the attention of the postgres crate’s author and hope to pick his brains for a solution.

Here: https://users.rust-lang.org/t/rust-postgres-and-openssl/33328/5

Thanks, we can continue the discussion on Github!

I’ll post your rust-lang thread there as well.

I now have a working secure connection to cockroachdb from Rust. See the github issue :

Thanks for the update!