sn_api and openssl dependency

I’m trying to build sn_api using musl and have a problem with openssl (which I thought was removed once before but seems to be back again, maybe I’m thinking of sn_node?).

My compile instruction:

sn_api (f2589e0) $ cargo build --release --target x86_64-unknown-linux-musl
...
error: failed to run custom build command for `openssl-sys v0.9.60`
... lots of error text ...

The openssl dependency comes from the reqwest crate

sn_api (f2589e0) $ cargo tree -i openssl
openssl v0.10.32
└── native-tls v0.2.6
    ├── hyper-tls v0.3.2
    │   └── reqwest v0.9.24
    │       └── sn_cli v0.17.0 (/home/ian/code/maidsafe/sn_api/sn_cli)
    └── reqwest v0.9.24 (*)

reqwest says it depends on openssl (but only for linux) in their readme:

Reqwest uses rust-native-tls, which will use the operating system TLS framework if available, meaning Windows and macOS. On Linux, it will use OpenSSL 1.1.

Any thoughts about the best way to resolve this? Should I use gcc instead of musl?

1 Like

I thought we had got rid of that, there is a feature flag rustls-tls: which would get rid of the openssl dep. I hate these c/c++ deps as they break loads of issues like musl and make life crazy for wasm etc. as well.

1 Like

Ah yes there is

https://docs.rs/reqwest/0.10.9/reqwest/#optional-features

The following are a list of Cargo features that can be enabled or disabled:

rustls-tls: Enables TLS functionality provided by rustls

I added this change in sn_api/sn_cli/Cargo.toml

-reqwest = "~0.9.22"
+reqwest = { version = "~0.9.22", features = ["rustls-tls"] }

But it now fails to build with musl on crate ring v0.16.19 (source code and musl issue)

I will keep digging but will put this here in case anyone happens to know a simple response off the top of their head.

4 Likes

Sorry for the delayed response. I was away on holiday for a bit.

I poked this around and you were very close. This issue should now be resolved in this PR.
Let me know if you still have issues :slight_smile:

4 Likes

This error goes away by installing musl-tools, but I’m getting a dynamically linked binary by default, so I’m trying to re-create what we have in sn-node to properly build using musl-tools but statically-=linked binary. I’ve tried building sn-node myself and I hit the same ring error, so doing whatever we do in our sn-node CI (it seems we use a docker container) should hopefully work for CLI too.

2 Likes