Skip to content

Instantly share code, notes, and snippets.

@tristian2
Created March 9, 2016 15:56
Show Gist options
  • Save tristian2/2efce8798460f110d0c1 to your computer and use it in GitHub Desktop.
Save tristian2/2efce8798460f110d0c1 to your computer and use it in GitHub Desktop.
cls
$certPath = "C:\Certs\TrisOfficePnP.cer"
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($certPath)
$rawCert = $cert.GetRawCertData()
$base64Cert = [System.Convert]::ToBase64String($rawCert)
$rawCertHash = $cert.GetCertHash()
$base64CertHash = [System.Convert]::ToBase64String($rawCertHash)
$KeyId = [System.Guid]::NewGuid().ToString()
$keyCredentials =
'"keyCredentials": [
{
"customKeyIdentifier": "'+ $base64CertHash + '",
"keyId": "' + $KeyId + '",
"type": "AsymmetricX509Cert",
"usage": "Verify",
"value": "' + $base64Cert + '"
}
],'
$keyCredentials
Write-Host "Certificate Thumbprint:" $cert.ThumbprintEnter file contents here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment