-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Update CmsCommands to use Store vs cert provider
#11643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@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
|
|
I added WIP until the PR is ready to review. |
|
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 You should enable the cmdlets in DefaultCommands.Tests.ps1 too (See link above). |
|
This PR does not appear to conflict with #11590 |
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Outdated
Show resolved
Hide resolved
|
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. |
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Outdated
Show resolved
Hide resolved
|
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. |
PaulHigin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We still need to do a security review, but the code changes look good.
| if (subjectNamePattern.IsMatch(cert.Subject)) | ||
| { | ||
| certificatesToProcess.Add(cert); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mikeTWC1984 If you ask about this IsMatch() it is ok to preserve the old behavior until we get a negative feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Outdated
Show resolved
Hide resolved
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Outdated
Show resolved
Hide resolved
iSazonov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with two minor comments.
test/powershell/Modules/Microsoft.PowerShell.Security/CmsMessage2.Tests.ps1
Outdated
Show resolved
Hide resolved
|
@TravisEz13 I think this is ready for security review. I also filed Documentation issue. |
|
@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. |
|
@mikeTWC1984 Security review summary: we don't think the security footing of the cmdlet has changed. |
CmsCommands to use Store vs cert provider
|
@mikeTWC1984 Thanks for your contribution! |
|
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. |
|
@mikeTWC1984 Open new issue(s) if there is a field for discussion. |
|
🎉 Handy links: |
PR Summary
This PR replaces cert provider (windows only) with X509Store class to resolve certificate by name/thumbprint on CmsUtils.
PR Work items:
List<509Certificate2>with X509Certificate2Collection on related methods.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.