February 2019
Intermediate to advanced
626 pages
15h 51m
English
It is occasionally necessary to create certificates in very specific formats to appease other systems requiring such a certificate.
A certificate may be exported as a Base64 string as follows. The InsertLineBreaks option splits the string every 76 characters:
$certificate = Get-ChildItem Cert:\LocalMachine\Root | Select-Object -First 1[Convert]::ToBase64String( $certificate.Export('Cert'), [System.Base64FormattingOptions]::InsertLineBreaks)
If a different width is required, a regular expression may be used to tweak the format of the certificate—in this case, we split the lines every 64 characters:
$certificate = Get-ChildItem Cert:\LocalMachine\Root | Select-Object -First 1@( '-----BEGIN CERTIFICATE-----' [Convert]::ToBase64String( ...
Read now
Unlock full access