Skip to content

Instantly share code, notes, and snippets.

@jamietre
Created April 20, 2021 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamietre/2238970da046ed5e04c1593e86c9c945 to your computer and use it in GitHub Desktop.
Save jamietre/2238970da046ed5e04c1593e86c9c945 to your computer and use it in GitHub Desktop.
Import local issuer certificates to msys2
get-childitem -path cert:\LocalMachine\Root | ForEach-Object {
$hash = $_.GetCertHashString()
$base64certificate = @"
-----BEGIN CERTIFICATE-----
$([Convert]::ToBase64String($_.export('Cert'), [System.Base64FormattingOptions]::InsertLineBreaks))
-----END CERTIFICATE-----
"@
[System.IO.File]::AppendAllText("$home\windows.pem", $base64certificate)
}
@jamietre
Copy link
Author

jamietre commented Apr 20, 2021

This solves the problem of msys2 not working with corporate VPN running.

Powershell script to pull certificates from windows store from: msys2/MSYS2-packages#296 (comment)

When it finishes, copy "windows.pem" to /msys64/usr/ssl/certs/ca-bundle.crt

Script above fixes pacman. You also need to fix python. The same technique can be used, you can get the location of the py cert store within msys2:

echo "import certifi\nprint(certifi.where())" | python3

@jamietre
Copy link
Author

For node:

export NODE_EXTRA_CA_CERTS="C:\\msys64\\usr\\ssl\\certs\\ca-bundle.crt"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment