Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid dependency on libssl.so.10 and libcrypto.so.10

Tags:

rust

My handy little rust binary is working just fine when compiled and run on pretty much every system except the Ubuntu 18.04 I need it to run on. Why, you might ask?

error while loading shared libraries: libcrypto.so.10: cannot open shared object file: No such file or directory

For what it's worth, I'm sure it was complaining about libssl.so.10 previously - not sure what I did to make that go away.

Anyway, I gather the traditional fix for this is to update libssl - for reasons I won't bother going into here, I can't do that in this case. I've also tried symlinking libcrypto.so.1.0.0 - that just results in complaints about missing versions.

So, I'm hoping there's a way I can bundle this dependency into the binary instead of relying on it being available on the runtime system. I'm not sure at all how to go about this; can anyone suggest?

[dependencies]
async-trait = "0.1.48"
clap = "3.0.0-beta.2"
futures = "0.3"
rusoto_credential = "0.46.0"
rusoto_core = { version="0.46.0" }
rusoto_lambda = "0.46.0"
rusoto_sts = "0.46.0"
serde = "0.9"
serde_json = "0.9"
serde_derive = "0.9"
tokio = { version = "1", features = ["full"] }
like image 269
user1381745 Avatar asked Sep 02 '25 05:09

user1381745


1 Answers

Just add the following to your dependencies:

openssl = { version = "0.10", features = ["vendored"] }

and voila:

$ ldd target/debug/ssltest
        linux-vdso.so.1 (0x00007fffa538c000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7ab1a67000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7ab1a44000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7ab1a3e000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7ab184c000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f7ab2a07000)

See openssl crate documentation.

If the vendored Cargo feature is enabled, the openssl-src crate will be used to compile and statically link to a copy of OpenSSL.

like image 71
HHK Avatar answered Sep 05 '25 00:09

HHK