< Back
ConvertFrom-PrivateKeyPEM
Post
NAME ConvertFrom-PrivateKeyPEM
SYNOPSIS
Converts a PKCS#8 PEM private key to its appropriate crypto service provider.
SYNTAX
ConvertFrom-PrivateKeyPEM [-PEM] <String> [-AsICspAsymmetricAlgorithm] [<CommonParameters>]
ConvertFrom-PrivateKeyPEM -Path <String> [-AsICspAsymmetricAlgorithm] [<CommonParameters>]
DESCRIPTION
This cmdlet converts a PKCS#8 PEM private key to its .NET crypto service provider object.
Currently the cmdlet supports RSA and DSA keys.
PARAMETERS
-PEM <String>
The PEM content of the private 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 PRIVATE KEY-----
<base64encodedkeydata>
-----END PRIVATE KEY-----
"@
$CSP = ConvertFrom-PrivateKeyPEM -PEM $Key
This will convert the PEM file into the corresponding crypto service provider object.
RELATED LINKS
SYNOPSIS
Converts a PKCS#8 PEM private key to its appropriate crypto service provider.
SYNTAX
ConvertFrom-PrivateKeyPEM [-PEM] <String> [-AsICspAsymmetricAlgorithm] [<CommonParameters>]
ConvertFrom-PrivateKeyPEM -Path <String> [-AsICspAsymmetricAlgorithm] [<CommonParameters>]
DESCRIPTION
This cmdlet converts a PKCS#8 PEM private key to its .NET crypto service provider object.
Currently the cmdlet supports RSA and DSA keys.
PARAMETERS
-PEM <String>
The PEM content of the private 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 PRIVATE KEY-----
<base64encodedkeydata>
-----END PRIVATE KEY-----
"@
$CSP = ConvertFrom-PrivateKeyPEM -PEM $Key
This will convert the PEM file into the corresponding crypto service provider object.
RELATED LINKS