Using TLS With Rust: Getting OpenSSL to Work

DZone 's Guide to

Using TLS With Rust: Getting OpenSSL to Work

Learn more about how you can get OpenSSL working with Rust and TLS.

· Security Zone ·
Free Resource

After getting really frustrated with the state of Rust and TLS, I decided to sit down and figure out what it would take to make the OpenSSL crate actually build successfully. Even though the crate claims to support vcpkg, it seems that there were issues there. I started from a clean slate and checked that I have OpenSSL via vcpkg installed:


I then got into a rabbit hole of errors in the build:


This seems like it wants to statically link to them by default, but when I set the env variable, I got:


Looking closely at the error (always read the error message), you can see that it is looking for a 64 bits build, but I've got an x86 build.

That very likely explains the issues that I previously had. I tried to point it to the SSL build directory, and I’m pretty sure that I used the 32bits directory. It rejected the attempted link but it didn’t bother to tell me about it.

To be fair, this isn’t Rust’s fault; it is link.exe’s fault for not providing a clear error about this case. Actually, this is the case where you are going to invest some time writing a feature whose only purpose is to get good errors when the user messed up. But that kind of attention to detail makes a world of difference.

Here is what fixed this for me.


And with that, I can build using:


Hooray! That is enough for now, I guess. I’ll get things actually working in another post. Stay tuned!

security ,rust ,tls ,openssl ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}