Skip to content

Instantly share code, notes, and snippets.

@nmoinvaz
Last active May 24, 2023 10:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmoinvaz/ece15191a4a3d4a73fe9a78b812869a3 to your computer and use it in GitHub Desktop.
Save nmoinvaz/ece15191a4a3d4a73fe9a78b812869a3 to your computer and use it in GitHub Desktop.
Using Powershell to get the Public Key in hex from a certificate

To retrieve the public key from a PFX certificate using Powershell, use the following command:

$publicKey = (Get-PfxCertificate -FilePath mycert.pfx).GetPublicKey()

To convert the public key to a hex string without hyphens you can use this command:

[System.BitConverter]::ToString($publicKey).Replace("-", "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment