[Solved] SSL certificate error when running cargo update

UPDATE: Everything is working normal now. I ran rustup --update and now cargo is working fine. I'm not sure what caused the failure, or why rustup --update seemed to fix it.

Starting today I'm getting an SSL certificate error when running cargo update or trying to add any new crates to an existing project. Below is the output of cargo update --verbose.

Updating registry `https://github.com/rust-lang/crates.io-index`
error: failed to load source for a dependency on `libc`

Caused by:
  Unable to update registry https://github.com/rust-lang/crates.io-index

Caused by:
  failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  [16/-17] The SSL certificate is invalid

Is this an issue on my end, and is there any way to work around the issue?

UPDATE: Everything is working normal now. I ran rustup --update and now cargo is working fine. I'm not sure what caused the failure, or why rustup --update seemed to fix it though.

There was a regression in nightly Cargo recently that caused it not to initialize the certificate store location properly. rustup --update fixed it since it's been fixed upstream now.

1 Like