Skip to content

Instantly share code, notes, and snippets.

@voronenko-p
Created April 25, 2019 14:37
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 voronenko-p/2ed1119bc2dbd04aede266df04f436a4 to your computer and use it in GitHub Desktop.
Save voronenko-p/2ed1119bc2dbd04aede266df04f436a4 to your computer and use it in GitHub Desktop.
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
$url = "https://curl.haxx.se/ca/cacert.pem"
$output = "$PSScriptRoot\cacert.pem"
$certlocation = "Cert:\LocalMachine\Root"
Write-Host "Downloading $url to $output " -ForegroundColor "Yellow"
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
(New-Object System.Net.WebClient).DownloadFile($url, $output)
Write-Host "Converting to pfx with" -ForegroundColor "Yellow"
Write-Host "openssl pkcs12 -export -nokeys -out cacert.pfx -in cacert.pem" -ForegroundColor "White"
cmd /c "openssl pkcs12 -export -nokeys -out cacert.pfx -in cacert.pem -password pass:export"
Write-Host "Importing root certificates as" -ForegroundColor "Yellow"
Write-Host "Import-PfxCertificate –FilePath $PSScriptRoot\cacert.pfx Cert:\LocalMachine\Root" -ForegroundColor "White"
Import-PfxCertificate –FilePath $PSScriptRoot\cacert.pfx $certlocation -Password (ConvertTo-SecureString -String "export" -Force –AsPlainText)
Set-Location $certlocation
#Get the installed certificates in that location
Get-ChildItem | Format-Table Subject, FriendlyName, Thumbprint -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment