Split PFX into cert and key without password

Set-Location 'C:\OpenSSL-Win64\bin'
$PfxPath = "C:\Cert\cert.pfx"
$WorkingDirectory = [io.path]::GetDirectoryName($PfxPath)
$FileName = [io.path]::GetFileNameWithoutExtension($PfxPath)

#Password for the pfx file
$Password = "password"
	
$CertCommand = ".\openssl.exe pkcs12 -in $PfxPath  -out $("$WorkingDirectory\$FileName.crt") -nokeys -passin pass:$Password"
Invoke-Expression -Command $CertCommand
Start-Sleep 2
		
$KeyCommand = ".\openssl.exe pkcs12 -in $PfxPath -out $("$WorkingDirectory\$FileName.key") -nocerts -nodes -passin pass:$Password"
Invoke-Expression -Command $KeyCommand
This entry was posted in Uncategorized. Bookmark the permalink.