Skip to content

Instantly share code, notes, and snippets.

@jamietre
Created April 20, 2021 11:46
Show Gist options
  • Select an option

  • Save jamietre/2238970da046ed5e04c1593e86c9c945 to your computer and use it in GitHub Desktop.

Select an option

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

jamietre commented Apr 20, 2021

Copy link
Copy Markdown
Author

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
Copy Markdown
Author

For node:

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

@joaotavora

Copy link
Copy Markdown

You may need echo -e there to interpret the \n

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