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

fix handling of client cert on macOS #73574

Merged
merged 12 commits into from
Aug 16, 2022
Merged

fix handling of client cert on macOS #73574

merged 12 commits into from
Aug 16, 2022

Conversation

wfurt
Copy link
Member

@wfurt wfurt commented Aug 8, 2022

We did not build X509Chain when using specific client or server certificate (e.g. Without context).
We used to call X509Chain.Build inside of PAL but we don't any more. So the intermediate CA certificates would not be sent even if available in certificate stores.

This got missed by the existing test. Because of #48207 the prerequisites would never be satisfied and the test would always skip on macOS.
Also macOS can provide full chain (when certs are stored in Key Chain) even if the client did not sent everything.

To fix both the test is no longer conditional. Hopefully it will be stable enough in CI.

fixes #66537
contributes to #73295

@wfurt wfurt requested a review from a team August 8, 2022 16:54
@wfurt wfurt self-assigned this Aug 8, 2022
@ghost
Copy link

ghost commented Aug 8, 2022

Tagging subscribers to this area: @dotnet/ncl, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

We did not build X509Chain when using specific client or server certificate (e.g. Without context).
We used to call X509Chain.Build inside of PAL but we don't any more. So the intermediate CA certificates would not be sent even if available in certificate stores.

This got missed by the existing test. Because of #48207 the prerequisites would never be satisfied and the test would always skip on macOS.
Also macOS can provide full chain (when certs are stored in Key Chain) even if the client did not sent everything.

To fix both the test is no longer conditional. Hopefully it will be stable enough in CI.

fixes #66537
contributes to #73295

Author: wfurt
Assignees: wfurt
Labels:

area-System.Net.Security, os-mac-os-x

Milestone: -

@wfurt
Copy link
Member Author

wfurt commented Aug 9, 2022

Any idea why the X509Chain fails to build @bartonjs @vcsjones?
The test works locally and I think the product change is correct.
I can clearly see the generated certs added into Key Chain...

{
_output.WriteLine($" Status: {status.Status}: {status.StatusInformation}");
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Logging items from chain.ChainStatus may also be useful, in case there's an overall code it presented that didn't map to any individual element

Copy link
Member Author

Choose a reason for hiding this comment

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

        CN=SslStream_ClientCertificate_SendsChain, O=SslStream_ClientCertificate_SendsChain length 1
          Status:  PartialChain: One or more certificates required to validate this certificate cannot be found.
          ChainStatus: PartialChain One or more certificates required to validate this certificate cannot be found..

it seems like it cannot find the part certs.
That are in store dump AFAIK

        CN=A Revocation Test CA 0, O=SslStream_ClientCertificate_SendsChain
        CN=A Revocation Test Root, O=SslStream_ClientCertificate_SendsChain

Copy link
Member

Choose a reason for hiding this comment

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

Huh. I certainly would have expected the default keychain to be involved in a chain build; but I guess not. We probably don't have tests like this in the X509 suite because we don't like messing with system state.

Since there's not a flow where the client can provide their own chain context, you might just need to have this test leave the responder running, so the intermediate can be fetched from AIA. (Overload GenerateCertificates to out the responder instead of disposing it)

Copy link
Member Author

Choose a reason for hiding this comment

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

I did many runs on my local machines and it works fine. But there is something unusual about the CI machine ;(
I was thinking about making the test optional again but we lost coverage before and it hid valid issue.

And I can try the AIA. I did not like it for the servers as it make some of the test less predicable but I can try it for client.

Copy link
Member

Choose a reason for hiding this comment

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

I did many runs on my local machines and it works fine. But there is something unusual about the CI machine ;(

Now that sounds familiar :). IIRC it doesn't have a UI session, just an SSH session, and that makes some of the keychain systems behave oddly.

@wfurt
Copy link
Member Author

wfurt commented Aug 14, 2022

I did not figure out how to pass the test in CI. It runs locally and I have reasonable confidence the product change is right.
I disabled the test agains #73862 and I will investigate separately and I would still like to take this for 7.0.

Copy link
Member

@rzikm rzikm left a comment

Choose a reason for hiding this comment

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

LGTM

@wfurt wfurt merged commit 7d98116 into dotnet:main Aug 16, 2022
@wfurt wfurt deleted the macCCert branch August 16, 2022 03:23
@karelz karelz added this to the 7.0.0 milestone Aug 22, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intermediate Certs not being sent from client to server on MAC
5 participants