-1

my docker builds started failing today and I can't seem to figure out exactly how to fix it.

Compiling locally is still working. When I try to create a container of the project, I get this error:

error[E0599]: no method named `decrypt_padded_vec` found for struct `Decryptor` in the current scope
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/p12-0.6.2/src/lib.rs:660:9
    |
660 |     rc2.decrypt_padded_vec::<Pkcs7>(data).ok()
    |         ^^^^^^^^^^^^^^^^^^ method not found in `Decryptor<Rc2>`

error[E0599]: no method named `decrypt_padded_vec` found for struct `Decryptor` in the current scope
   --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/p12-0.6.2/src/lib.rs:700:10
    |
700 |     tdes.decrypt_padded_vec::<Pkcs7>(data).ok()
    |          ^^^^^^^^^^^^^^^^^^ method not found in `Decryptor<TdesEde3>`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `p12` due to 2 previous errors

One thing I noticed is that the crate p12 is being built with 0.6.2 and my local Cargo.lock uses 0.6.0, could this be the problem?

This is my Cargo.toml:

[dependencies]
actix="0.12.0"
actix-rt="2.6.0"
futures-util = "0.3.21"
tokio-tungstenite = {version = "0.16.1", features=["native-tls"]}
tokio = {version = "1.16.1"}
tokio-rustls = "0.22.0"
url = "2.2.2"
serde = {version="1.0", features=["serde_derive", "derive"]}
serde_json = "1.0.78"
log = "0.4.14"
dashmap = "5.0.0"
lapin = { version = "2.0.1", features=["rustls"] }
log4rs = "1.0.0"
dotenv = "0.15.0"
rustls = {version="0.19.1", features=["dangerous_configuration"]}
reqwest = "0.11.9"
clap = { version = "3.0.14", features = ["derive"] }

[dependencies.uuid]
features = ["v4", "serde", "v5"]
version = "0.8.2"

[dependencies.sqlx]
default_features = false
features = ["postgres", "macros", "chrono", "runtime-actix-rustls", "uuid", "offline"]
version = "0.5.9"

And this is my dockerfile:

FROM rust:1.57-slim as base
ENV USER=root
ENV SQLX_OFFLINE=true

WORKDIR /code
RUN cargo init
COPY sqlx-data.json /code/sqlx-data.json
COPY Cargo.toml /code/Cargo.toml
COPY .env /code/.env
COPY logging_config.yaml /code/logging_config.yaml
RUN apt-get update -y
RUN apt-get install apt-utils
RUN apt-get install -y pkg-config
RUN apt-get install -y libssl-dev

# Cargo fetch is super slow (sometimes)
RUN cargo fetch
# RUN git fetch --force --update-head-ok 'https://github.com/rust-lang/crates.io-index' 'refs/heads/master:refs/remotes/origin/master' 'HEAD:refs/remotes/origin/HEAD'
COPY src /code/src

FROM base as builder
RUN cargo build --release

FROM builder
COPY --from=builder /code/target/release/robot-websocket-client /usr/bin/robot-websocket-client

CMD ["/usr/bin/robot-websocket-client", "-r", "fakebot"]

For now, I think that the culprit is the different version of v0.6.2, but setting the specific version within the Cargo.toml file did not solve the problem.

Any insights would be appreciated. Please let me know if you need more information. Thank you,

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Fabrex
  • 162
  • 9
  • 1
    You should file an issue on the `p12` repository. The error is nothing you've done wrong since it is coming from within the library. Also [version 0.6.2](https://crates.io/crates/p12/versions) looks brand new so they might not know about any problems yet. – kmdreko Feb 17 '22 at 02:54
  • Hm, your Dockerfile is relatively irrelevant to the problem. I considered editing/deleting it from your post. Anyway, a comment on it: You should do the apt-get installations at the top of the dockerfile, and maybe one step: `RUN apt-get update -y && apt-get install -y apt-utils pkg-config libssl-dev`. This will avoid having to re-install the packages everytime your Cargo.toml changes. – Caesar Feb 17 '22 at 07:52
  • 1
    I've looked into the [cause](https://github.com/RustCrypto/traits/pull/941#issue-1140180583) a bit. Maybe the `Dockerfile` is relevant to your problem after all: You should keep a `Cargo.lock` file, and copy it into the `Dockerfile`, and do your builds with `cargo build --release --locked`. That will prevent such random dependency version upgrades from breaking your build. – Caesar Feb 17 '22 at 08:17
  • Thank you for your comments. I had indeed found this as a possible solution, but I'm not sure it will lead to problems down the line. Can you share your thoughts or your experience with that? Thank you – Fabrex Feb 23 '22 at 02:32

1 Answers1

1

You can dictate a specific dependency version via =X.Y.Z in cargo.toml. This seems to fix it:

p12 = "=0.6.0"
kmdreko
  • 42,554
  • 6
  • 57
  • 106
  • Thank you, this seems to be a better solution than keeping a copy of the cargo.lock inside the container. – Fabrex Feb 23 '22 at 02:31