< Back

ConvertFrom-PublicKeyPEM

Sat Jan 11, 2020 12:42 pm

NAME ConvertFrom-PublicKeyPEM



SYNOPSIS

Converts a PEM file to its appropriate CryptoServiceProvider object, or ICspAsymmetricAlgorithm interface.





SYNTAX

ConvertFrom-PublicKeyPEM [-PEM] <String> [-AsICspAsymmetricAlgorithm] [<CommonParameters>]



ConvertFrom-PublicKeyPEM -Path <String> [-AsICspAsymmetricAlgorithm] [<CommonParameters>]





DESCRIPTION

This cmdlet takes a PEM file contents and converts to its appropriate CryptoServiceProvider object, or

ICspAsymmetricAlgorithm interface.



This supports RSA and DSA keys.





PARAMETERS

-PEM <String>

The PEM content of the Public Key. This can either be the complete PEM file contents

or just the base64 encoded data.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Path <String>

The path to a properly encoded PEM file with the appropriate Header and Footer text.



The file can only contain a single key, subsequent keys in the same file will be ignored.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-AsICspAsymmetricAlgorithm [<SwitchParameter>]

Specifies that the output will be an ICspAsymmetricAlgorithm interface instead of the concrete crypto

service provider object.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.String





OUTPUTS

System.Security.Cryptography.RSACryptoServiceProvider, System.Security.Cryptography.DSACryptoServiceProvider,

System.Security.Cryptography.ICspAsymmetricAlgorithm





NOTES





AUTHOR: Michael Haken

LAST UPDATE: 1/26/2018



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>$Key = @"



-----BEGIN PUBLIC KEY-----

<base64encodedkeydata>

-----END PUBLIC KEY-----

"@



$CSP = ConvertFrom-PublicKeyPEM -PEM $Key



This will convert the PEM file into the corresponding crypto service provider object.











RELATED LINKS