-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Description
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.
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues