FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Update `CmsCommands` to use Store vs cert provider by mikeTWC1984 · Pull Request #11643 · PowerShell/PowerShell · GitHub

Update CmsCommands to use Store vs cert provider - #11643

Merged
Travis Plunk (TravisEz13) merged 25 commits into
PowerShell:masterfrom
mikeTWC1984:master
Feb 6, 2020
Merged

Update CmsCommands to use Store vs cert provider#11643
Travis Plunk (TravisEz13) merged 25 commits into
PowerShell:masterfrom
mikeTWC1984:master

Conversation

mikeTWC1984 commented Jan 21, 2020
edited
Loading

Copy link
Copy Markdown
Contributor

PR Summary

This PR replaces cert provider (windows only) with X509Store class to resolve certificate by name/thumbprint on CmsUtils.

PR Work items:

  • ResolveFromSubjectName and ResolveFromThumbprint - remove cert: provider call and merge into single method ( both lookups can utilize X509Certificate2Collection.Find )
  • Remove GetCertEKU (that uses native calls). Use X509Certificate2 Extensions property instead in CertHasOId method.
  • LocalMachine/My store - Windows only
  • replace List<509Certificate2> with X509Certificate2Collection on related methods.
  • Update tests
  • test on Mac
  • add wildcard for subjectname lookup

PR Checklist

ghost assigned Ilya (iSazonov) Jan 21, 2020

Microsoft Contribution License Agreements (msftclas) commented Jan 21, 2020
edited
Loading

Copy link
Copy Markdown


All CLA requirements met.

Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jan 22, 2020
Ilya (iSazonov) added this to the 7.1.0-preview.1 milestone Jan 22, 2020

Ilya (iSazonov) commented Jan 22, 2020
edited by unfurl-links Bot
Loading

Copy link
Copy Markdown
Collaborator

mikeTWC1984 We should export the cmdlets on Unix-s:

Also please review tests https://github.com/PowerShell/PowerShell/tree/master/test/powershell/Modules/Microsoft.PowerShell.Security

GitHub
PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
GitHub
PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.

Ilya (iSazonov) changed the title updated CmsCommands to use Store vs cert provider WIP: Update CmsCommands to use Store vs cert provider Jan 23, 2020

Copy link
Copy Markdown
Collaborator

I added WIP until the PR is ready to review.

mikeTWC1984 changed the title WIP: Update CmsCommands to use Store vs cert provider Update CmsCommands to use Store vs cert provider Jan 23, 2020
mikeTWC1984 changed the title Update CmsCommands to use Store vs cert provider WIP: Update CmsCommands to use Store vs cert provider Jan 23, 2020

Copy link
Copy Markdown
Contributor Author

OK. It's pretty much ready for review, but somehow Powershell-CI pester test is failing. I ran 3 tests today, all failed for linux, 2 for Mac and 1 for Windows. I also tried Start-PSPester locally for my branch and Powershell's master and got ~30 errors. A the moment it's not quite clear what's wrong. . Probably some temp issue, will keep experimenting. The build itself goes through, CMS commands seem to work, but I haven't done thorough testing yet.

mikeTWC1984 changed the title WIP: Update CmsCommands to use Store vs cert provider Update CmsCommands to use Store vs cert provider Jan 24, 2020

Copy link
Copy Markdown
Collaborator

mikeTWC1984 You should enable the cmdlets in DefaultCommands.Tests.ps1 too (See link above).

Copy link
Copy Markdown
Contributor

This PR does not appear to conflict with #11590

Copy link
Copy Markdown
Contributor Author

OK, tests finally pass on Mac. Turns out certs got added to the store automatically during creation (X509Store.add actually doesn't work ) . I'll work on the Doc today or tomorrow.

ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Feb 4, 2020
ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Feb 4, 2020

mikeTWC1984 commented Feb 4, 2020
edited
Loading

Copy link
Copy Markdown
Contributor Author

Ok, applied all the latest changes. I was back and forth between using CertificateCollection.Find and foreach loop to match SubjectName, and I'm finally sticking with foreach, so it's the same approach as original version had. I realized find will always do "contains" match, but I guess mostly user would need exact match.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM
We still need to do a security review, but the code changes look good.

Comment on lines +1273 to +1276
if (subjectNamePattern.IsMatch(cert.Subject))
{
certificatesToProcess.Add(cert);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

mikeTWC1984 If you ask about this IsMatch() it is ok to preserve the old behavior until we get a negative feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This one is OK. It's bit counterintuitive to use wildcard (and directory) when expecting single item, but helps when typing those names manually. After going back and forth with this, I realized omitting CN= prefix in subject name would be very useful, so I added one extra IsMatch for simple name too

Ilya (iSazonov) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM with two minor comments.

Copy link
Copy Markdown
Contributor Author

Travis Plunk (@TravisEz13) I think this is ready for security review. I also filed Documentation issue.

Copy link
Copy Markdown
Member

mikeTWC1984 Yes, I've already schedule the review. The reviews are Confidential and we have to decide how to communicate the results after the review.

Copy link
Copy Markdown
Member

mikeTWC1984 Security review summary: we don't think the security footing of the cmdlet has changed.

Travis Plunk (TravisEz13) changed the title Update CmsCommands to use Store vs cert provider Update CmsCommands to use Store vs cert provider Feb 6, 2020
Travis Plunk (TravisEz13) merged commit 69bf704 into PowerShell:master Feb 6, 2020

Copy link
Copy Markdown
Collaborator

mikeTWC1984 Thanks for your contribution!

Copy link
Copy Markdown
Contributor Author

Cool, thanks all. There are few enhancements we can add to those commands, I'll probably submit an issue or PR sometime soon. I guess it's also the time to update documentation, will work on that.

Copy link
Copy Markdown
Collaborator

mikeTWC1984 Open new issue(s) if there is a field for discussion.

Copy link
Copy Markdown

🎉v7.1.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

microsoft-github-policy-service Bot added the In-PR Indicates that a PR is out for the issue label Feb 4, 2025
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log In-PR Indicates that a PR is out for the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL