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:
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: and here: Each of which ends up with similar unresolved messages.

My Cargo.toml file currently contains this:

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

Any chance this was created by you?


Indeed that was me.

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


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!