Skip to content
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

Bring back Certificate provider parameters #10622

Merged
merged 3 commits into from
Jun 2, 2020

Conversation

iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Sep 25, 2019

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

@iSazonov iSazonov added Documentation Needed in this repo Documentation is needed in this repo CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log labels Sep 25, 2019
@iSazonov iSazonov added this to the 7.0.0-preview.5 milestone Sep 25, 2019
@iSazonov
Copy link
Collaborator Author

iSazonov commented Sep 25, 2019

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.

Copy link
Member

@TravisEz13 TravisEz13 left a comment

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
Member

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

@iSazonov 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
Collaborator Author

Add WIP while waiting security review.

/// <param name="cert">Certificate object.</param>
/// <param name="pattern">Wildcard pattern for DNS name to search.</param>
/// <returns>True on success, false otherwise.</returns>
internal static bool CertContainsName(X509Certificate2 cert, WildcardPattern pattern)
Copy link
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?

Copy link
Collaborator Author

@iSazonov iSazonov Oct 4, 2019

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
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
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
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?

@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
Contributor

@PaulHigin PaulHigin left a comment

Choose a reason for hiding this comment

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

LGTM

@TravisEz13
Copy link
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
Collaborator Author

iSazonov commented Oct 8, 2019

@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 TravisEz13 added this to the 7.1.0-preview.1 milestone Nov 23, 2019
@TravisEz13
Copy link
Member

@PoshChan Please remind me in 24 hours

@PoshChan
Copy link
Collaborator

@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

ghost commented May 30, 2020

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
Member

Can you resolve the conflicts?

@ghost ghost removed the Review - Needed The PR is being reviewed label May 30, 2020
@TravisEz13 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 TravisEz13 closed this Jun 1, 2020
@TravisEz13 TravisEz13 reopened this Jun 1, 2020
@TravisEz13
Copy link
Member

@PoshChan Please remind me in 1 hour

@PoshChan
Copy link
Collaborator

PoshChan commented Jun 1, 2020

@TravisEz13, this is the reminder you requested 1 hour ago

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

ghost commented Jun 25, 2020

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

Handy links:

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.

None yet

5 participants