At the moment CmsCommands (Encrypting/Decrypting text with X509 cert) are only available on Windows. Those commands can be implemented with standard .net libraries, the only reason it's not working on Linux systems is that Util function that resolves certificate from string is using Cert: provider (which only implemented for Windows). Replacing cert: with X509Store class will make it work on linix systems.
here is the Util:
|
internal static class CmsUtils |
There are few lines referring to Cert:, for example
string certificatePath = sessionState.Path.Combine("Microsoft.PowerShell.Security\\Certificate::CurrentUser\\My", _identifier);
if (sessionState.InvokeProvider.Item.Exists(certificatePath))
{
foreach (PSObject certificateObject in sessionState.InvokeProvider.Item.Get(certificatePath))
{
certificates.Add(certificateObject);
}
}
Issue can be fixed by replacing it with something like that:
X509Store store = new X509Store(StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
certificatesToProcess = store.Certificates.Find(X509FindType.FindBySubjectName,_identifier,false);
This only affect ResolveFromSubjectName and ResolveFromThumbprint methods, so change is relatively small. I played with it on Ubuntu and didn't noticed any extra problems.
At the moment CmsCommands (Encrypting/Decrypting text with X509 cert) are only available on Windows. Those commands can be implemented with standard .net libraries, the only reason it's not working on Linux systems is that Util function that resolves certificate from string is using Cert: provider (which only implemented for Windows). Replacing cert: with X509Store class will make it work on linix systems.
here is the Util:
PowerShell/src/System.Management.Automation/security/SecuritySupport.cs
Line 972 in d58a82a
There are few lines referring to Cert:, for example
Issue can be fixed by replacing it with something like that:
This only affect ResolveFromSubjectName and ResolveFromThumbprint methods, so change is relatively small. I played with it on Ubuntu and didn't noticed any extra problems.