Skip to content

Bring back Certificate provider parameters - #10622

Merged
Travis Plunk (TravisEz13) merged 3 commits into
PowerShell:masterfrom
iSazonov:add-expiringindays
Jun 2, 2020
Merged

Bring back Certificate provider parameters#10622
Travis Plunk (TravisEz13) merged 3 commits into
PowerShell:masterfrom
iSazonov:add-expiringindays

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Sep 25, 2019

Copy link
Copy Markdown
Collaborator

PR Summary

  1. Bring back Certificate provider parameters:

    • DNSName
    • DocumentEncryptionCert
    • EKU
    • ExpiringInDays
    • SSLServerAuthentication
  2. Add new tests and update existing tests. (There are many style issues - will fix in follow PR.)

  3. Update test certificate for EKU and DNSName tests.

  4. Remove old unneeded code.

PR Context

Related #3847

After removing undocumented certificate API in PR #3818 we lost some parameters in Certificate provider.

We need to review documentation because the parameters is not all documented and it seems they do not always documented correctly.
(For reference https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/about/about_certificate_provider?view=powershell-6)

PR Checklist

Comment thread src/Microsoft.PowerShell.Security/security/CertificateProvider.cs Outdated
Comment thread src/Microsoft.PowerShell.Security/security/CertificateProvider.cs Outdated
Comment thread src/Microsoft.PowerShell.Security/security/CertificateProvider.cs Outdated
Comment thread src/Microsoft.PowerShell.Security/security/CertificateProvider.cs Outdated
@iSazonov

Ilya (iSazonov) commented Sep 25, 2019

Copy link
Copy Markdown
Collaborator Author

It seems Get-PfxCertificate crush the pwsh process if open "GoodCertificate" which I updated. All works well on Windows and Linux but fail on MacOs. Looks like a bug on MacOs. At least pwsh should return an error and doesn't crush.
I haven't MacOs and can not investigate in depth. I need help to resolve the issue.

@TravisEz13 Travis Plunk (TravisEz13) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This change requires a security review

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Sep 25, 2019
@TravisEz13

Copy link
Copy Markdown
Member

Ilya (@iSazonov) I don't have time to review now. Blocking this PR, until I can organize a security review.

@iSazonov Ilya (iSazonov) changed the title Bring back Certificate provider parameters WIP: Bring back Certificate provider parameters Sep 26, 2019
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Sep 26, 2019
@iSazonov

Copy link
Copy Markdown
Collaborator Author

Add WIP while waiting security review.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have you verified this will work with punycode?

@iSazonov Ilya (iSazonov) Oct 4, 2019

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Do you mean that Windows PowerShell support also punycode in dnsname filter? I did not find this in docs https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/about/about_certificate_provider?view=powershell-6

What is a scenario where it could be used?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When the name in the cert is in punycode. This is a compliance requirement. you deleted the code to do this.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Clear about compliance. Not clear what code do you mean.
Also docs say:

DnsName <Microsoft.PowerShell.Commands.DnsNameRepresentation>
This parameter gets certificates that have the specified domain name or name pattern in the DNSNameList property of the certificate. The value of this parameter can either be "Unicode" or "ASCII". Punycode values are converted to Unicode. Wildcard characters (*) are permitted.

It is not clear how punycode converted to Unicode. It seems this did unpublic code (in P/Invoke) which we removed long ago.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I looked original code which was removed and see only one difference - DNSName parameter was DnsNameRepresentation type, now string.
In both cases DnsNameRepresentation is initialized by one constructor with string parameter which assigned to DNSname and punycode - no conversion. So new code works for punycode.
Question is should we change type from string to DnsNameRepresentation?

Comment thread src/Microsoft.PowerShell.Security/security/CertificateProvider.cs Outdated
Comment thread src/Microsoft.PowerShell.Security/security/CertificateProvider.cs Outdated
Comment thread src/System.Management.Automation/security/SecuritySupport.cs Outdated
Comment thread src/System.Management.Automation/security/SecuritySupport.cs Outdated
@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Oct 4, 2019

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.

LGTM

@TravisEz13

Copy link
Copy Markdown
Member

macOS tests are hanging

  Describing CmsMessage cmdlets and Get-PfxCertificate basic tests
Certificate written to /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/protectedCert.pfx
Enter password:                                                                                                                                                                                                                                                                                                                                 
Execution of { & $powershell $PSFlags -c $command } by build.psm1: line 1231 failed with exit code 1
At /Users/vsts/agent/2.158.0/work/1/s/build.psm1:2074 char:17
+                 throw $errorMessage
+                 ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : OperationStopped: (Execution of { & $p\u2026ed with exit code 1:String) [], RuntimeException
+ FullyQualifiedErrorId : Execution of { & $powershell $PSFlags -c $command } by build.psm1: line 1231 failed with exit code 1

@iSazonov

Copy link
Copy Markdown
Collaborator Author

Travis Plunk (@TravisEz13)

macOS tests are hanging

I did not change anything except the certificate. I tend to think it's a bug outside PowerShell :-(
I haven't MacOs and I only can revert to old certificate and generate new for new tests to
minimize area.

@TravisEz13

Copy link
Copy Markdown
Member

PoshChan-Bot (@PoshChan) Please remind me in 24 hours

@PoshChan

Copy link
Copy Markdown
Collaborator

Travis Plunk (@TravisEz13), this is the reminder you requested 24 hours ago

@ghost ghost added the Review - Needed The PR is being reviewed label May 30, 2020
@ghost

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Mainainer, Please provide feedback and/or mark it as Waiting on Author

@TravisEz13

Copy link
Copy Markdown
Member

Can you resolve the conflicts?

@ghost ghost removed the Review - Needed The PR is being reviewed label May 30, 2020
@TravisEz13 Travis Plunk (TravisEz13) added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label May 30, 2020
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label May 31, 2020
@TravisEz13

Copy link
Copy Markdown
Member

PoshChan-Bot (@PoshChan) Please remind me in 1 hour

@PoshChan

Copy link
Copy Markdown
Collaborator

Travis Plunk (@TravisEz13), this is the reminder you requested 1 hour ago

@TravisEz13
Travis Plunk (TravisEz13) merged commit 73e8427 into PowerShell:master Jun 2, 2020
@iSazonov
Ilya (iSazonov) deleted the add-expiringindays branch June 3, 2020 02:57
@iSazonov Ilya (iSazonov) removed the Documentation Needed in this repo Documentation is needed in this repo label Jun 3, 2020
@ghost

Copy link
Copy Markdown

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

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants