Can't init opam on Windows WSL2 because of certificate issue


I am trying to initialize opam on Windows WSL2.

here is the error:

This seems to be caused by certificate issue:

if you use wget _, you will see that

ERROR: cannot verify’s certificate, issued by ‘CN=R3,O=Let’s Encrypt,C=US’:
Issued certificate has expired.

Any idea to work around this issue?


1 Like

I’m actually getting the same error on macOS:

$ opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><>  🐫 
[ERROR] Could not update repository "default": OpamDownload.Download_fail(_, "Curl failed: \"/usr/bin/curl --write-out
        %{http_code}\\\\n --retry 3 --retry-delay 2 --user-agent opam/2.0.5 -L -o
        /private/var/folders/xg/6jbw_1bj5h35b4lt7rygs12w0000gn/T/opam-20574-4bcc67/index.tar.gz.part\" exited with code 60")

Curl directly:

$ curl -o /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL certificate problem: certificate has expired
More details here:

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

This is what fixed the issue. The WSL2 ubuntu distribution I just installed today from Microsoft Store. The ca-certificates file inside it is outdated. After I did “sudo apt update” and “sudo apt upgrade” inside the ubuntu distro, which updates the ca-certificates. It is working now!

1 Like