PEMEncrypt icon indicating copy to clipboard operation
PEMEncrypt copied to clipboard

Exception calling the Encrypt function

Open mosesmosheh opened this issue 4 years ago • 2 comments

When executing your command: $encrypted = "Hello","How are you" | Protect-PEMString -PublicKey .\mykey.pub PowerShell throws the Exception Error

Protect-PEMString : Exception calling "Encrypt" with "2" argument(s): "Object reference not set to an instance of an
object."
At line:1 char:38
+ ... Hello","How are you" | Protect-PEMString -PublicKey .\mykey.pub
+                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Protect-PEMString], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException,Protect-PEMString

I am using PowerShell Version 5.1.17763.1490 and version 0.2.1 of the PEMEncrypt module.

mosesmosheh avatar Feb 24 '21 17:02 mosesmosheh

heya @mosesmosheh - can you try explicitly importing the module before running that command? Also, assuming that public key you're trying to use exists at that path, is that public key an RSA key or another protocol?

scrthq avatar Feb 26 '21 01:02 scrthq

Replicating this everywhere myself, unexpectedly, since this hasn't really changed in a while. Working on troubleshooting, thanks for the report!

scrthq avatar Feb 26 '21 01:02 scrthq