Skip to content

Instantly share code, notes, and snippets.

@kategray
Last active April 9, 2021 23:44
Show Gist options
  • Save kategray/9a6b4ed81820998087ec79d9b2593606 to your computer and use it in GitHub Desktop.
Save kategray/9a6b4ed81820998087ec79d9b2593606 to your computer and use it in GitHub Desktop.
Convert a cisco PKCS12 (PEM/text format) to a binary P12 for OpenSSL
#
# Opens up keypair.txt and writes to keypair.p12
#
# Skip the first and last lines, and trim any whitespace
$text = (Get-Content keypair.txt | Select-Object -skip 1 | Select-Object -skiplast 1).Trim()
# Convert from Base64 to Bytes
$bytes = [System.Convert]::FromBase64String($text)
# Write the content to keypair.p12
Set-Content keypair.p12 -Value $bytes -Encoding Byte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment