Files
Work-Tools/Scissors.ps1

26 lines
868 B
PowerShell

#Scissors - Quick and Dirty Script for extracting private key and certificate from an exported PFX.
cls
#Get Cert path
$path = Read-Host "Where is the pfx?"
$pass = Read-Host "What is the pfx Password?"
#Create function Open-Explorer to open the location of the cert - Strips cert.pfx from the $path variable leaving you the folder path. - I know there is easier ways to do this but I just want someone to love me.
function Open-Explorer {
param(
[string]$FilePath
)
$Folder = Split-Path $FilePath -Parent
explorer.exe $Folder
}
#Seperate certs
openssl pkcs12 -in $path -nocerts -out private_key.pem -nodes -password pass:$pass
openssl pkcs12 -in $path -clcerts -nokeys -out public_cert.pem -password pass:$pass
openssl pkcs12 -in $path -cacerts -nokeys -out cert_chain.pem -password pass:$pass
Write-host "Jobs done"
Open-Explorer $path