Title: CmsCommands - simple fix for linux · Issue #11630 · PowerShell/PowerShell · GitHub
Open Graph Title: CmsCommands - simple fix for linux · Issue #11630 · PowerShell/PowerShell
X Title: CmsCommands - simple fix for linux · Issue #11630 · PowerShell/PowerShell
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 ...
Open Graph 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...
X 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 wor...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/11630
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CmsCommands - simple fix for linux","articleBody":"\r\nAt the moment [CmsCommands](https://github.com/PowerShell/PowerShell/blob/3923ca172854b8f3b00dcd02b0f1829917758f10/src/Microsoft.PowerShell.Security/security/CmsCommands.cs) (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.\r\n\r\nhere is the Util:\r\nhttps://github.com/PowerShell/PowerShell/blob/d58a82ad19fbfad81e85778c8b08cb1b28f58fce/src/System.Management.Automation/security/SecuritySupport.cs#L972\r\n\r\nThere are few lines referring to Cert:, for example\r\n\r\n\r\n```\r\n string certificatePath = sessionState.Path.Combine(\"Microsoft.PowerShell.Security\\\\Certificate::CurrentUser\\\\My\", _identifier);\r\n if (sessionState.InvokeProvider.Item.Exists(certificatePath))\r\n {\r\n foreach (PSObject certificateObject in sessionState.InvokeProvider.Item.Get(certificatePath))\r\n {\r\n certificates.Add(certificateObject);\r\n }\r\n }\r\n```\r\nIssue can be fixed by replacing it with something like that:\r\n```\r\nX509Store store = new X509Store(StoreLocation.CurrentUser);\r\nstore.Open(OpenFlags.ReadOnly);\r\n certificatesToProcess = store.Certificates.Find(X509FindType.FindBySubjectName,_identifier,false);\r\n```\r\n\r\nThis only affect ResolveFromSubjectName and ResolveFromThumbprint methods, so change is relatively small. I played with it on Ubuntu and didn't noticed any extra problems.\r\n","author":{"url":"https://github.com/mikeTWC1984","@type":"Person","name":"mikeTWC1984"},"datePublished":"2020-01-20T03:00:20Z","url":"https://github.com/PowerShell/PowerShell/issues/11630"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:54a1dbf1-ccce-eb6c-46f8-48cec82b585a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BEDA:35901F:1F426A:2A1132:6AFD4482 |
| html-safe-nonce | c7d3a7bbd75fa414f01edf410c09c742795d7c5b063445d6d67cce249b693187 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRURBOjM1OTAxRjoxRjQyNkE6MkExMTMyOjZBRkQ0NDgyIiwidmlzaXRvcl9pZCI6IjU0OTA0ODAwNzc1MjA4NDgwMDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3faac9047fceaecc7cd543aa434f33e0b6e2827e2f8b9b01fba3e630b25a3bbe |
| hovercard-subject-tag | issue:552039584 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/11630/issue_layout |
| twitter:image | https://opengraph.githubassets.com/86ec3d466dbeb01f92ab491986a1ae902cd684095db498e2086c5d1a1375812e/PowerShell/PowerShell/issues/11630 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/86ec3d466dbeb01f92ab491986a1ae902cd684095db498e2086c5d1a1375812e/PowerShell/PowerShell/issues/11630 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mikeTWC1984 |
| hostname | github.com |
| expected-hostname | github.com |
| None | bdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 556dd37bb0aceffb25724e151b5d858b3265b40b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width