EvotecIT / PSPGP

PSPGP is a PowerShell module that provides PGP functionality in PowerShell. It allows encrypting and decrypting files/folders and strings using PGP.
MIT License
57 stars 21 forks source link

PSPGP conflicting with Az.KeyVault (4.*) #14

Closed phanvinh0526 closed 10 months ago

phanvinh0526 commented 1 year ago

Hi,

I build a Azure Function to encrypt a file with the public key stored in Key Vault secret (base64 encoded)

Anytime, I import-module az.keyvault and pspgpg, the issue will occur as the screenshot attached. Error Message: ERROR: Assembly with same name is already loaded

I tried different ways from Remov-Module before call a new function from PSPGP (IE: Protect-PGP), but we got the same issue. After searching around, I found that PSPGP may import some modules with Az.KeyVault, which cause conflict

Please advise if there is a work around on this

Regards

Screen Shot 2023-03-17 at 11 20 14 pm
PrzemyslawKlys commented 1 year ago

PSPGP uses two libraries.

image

Az.KeyVault:

image

The conflict is probably around BouncyCastle.Crypto.dll and those 2 modules having different versions. What may work is simply copying BouncyCastle.Crypto from Az.KeyVault to PSPGP and see if it works. If it does we may need to update it (or downgrade it), if it doesn't .. there's more work to be done.

Would be good to find out what versions both modules use

phanvinh0526 commented 1 year ago

Thank you for your response,

I am building a function on Azure Function to encrypt the flat file. There is a challenge when I try to input public key to Protect-PGP cmdlet

Since Azure Function doesn't support local storage, everything has to store in Storage Account, so I have to store public key and data file in memory. Do you know if possible to do that with this library?

Regards

PrzemyslawKlys commented 1 year ago

It should be possible. Tehre are many options available including a stream. So we could force it to take a string, convert it to stream and push it as stream

image

PrzemyslawKlys commented 10 months ago

Please try new version. Maybe it will help.