Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

macOS: Allow loading first X509 certificate from PEM sequence - #35322

Merged
bartonjs merged 6 commits into
dotnet:masterfrom
vcsjones:fix-29910
Feb 15, 2019
Merged

bartonjs merged 6 commits into
dotnet:masterfrom
vcsjones:fix-29910

Conversation

@vcsjones

@vcsjones vcsjones commented Feb 14, 2019 •

Copy link
Copy Markdown
Member

AppleCryptoNative_X509GetContentType is currently returning PAL_X509Unknown when attempting to load (or use GetCertContentType) on a file that contains multiple PEM encoded certificates.

Windows and OpenSSL currently treat it as a single certificate by only using the first certificate in the file. This fixes AppleCryptoNative_X509GetContentType to return PAL_Certificate if it is an aggregate of X509 certificates and match the behavior of other platforms.

Fixing also fixes loading the certificate since macOS isn't ambiguous as to what is trying to be done, so it starts loading the first certificate in the PEM sequence as well.

Fixes #29910

/cc @bartonjs

@vcsjones

Copy link
Copy Markdown
Member Author

@dotnet-bot test this please (Doesn't look related to my changes...)

@vcsjones

Copy link
Copy Markdown
Member Author

/azp help

@azure-pipelines

Copy link
Copy Markdown
Supported commands
     help:
          Get descriptions, examples and documentation about supported commands
          Example: help "command_name"
     run:
          Run all pipelines or a specific pipeline for this repository using a comment. Use
          this command by itself to trigger all related pipelines, or specify a pipeline
          to run.
          Example: "run" or "run pipeline_name"

See additional documentation.

@vcsjones

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

@vcsjones

Copy link
Copy Markdown
Member Author

... that did not do what I expected it to do. @safern halp?

@safern

safern commented Feb 14, 2019

Copy link
Copy Markdown
Member

... that did not do what I expected it to do. @safern halp?

"/azp run" without specifying a build definition, will run all including outerloop builds.

if you want to just run corefx-ci you have to do "/azp run corefx-ci" -- running an individual leg i.e corefx-ci (Windows -x64 Debug) is not yet supported 😢

The reason why jobs show as duplicated when you run them, is because azure devops has a bug which I reported, please see this thread, where I explain the bug #35126 (comment)

I'm working on adding the docs to explain all this, just been doing it in parallel with other stuff I have to do. I expect it today or tomorrow to be done.

@vcsjones

Copy link
Copy Markdown
Member Author

@safern

if you want to just run corefx-ci you have to do "/azp run corefx-ci"

OK, makes sense. I'll be sure to do that unless I intend on running outer loop.

The reason why jobs show as duplicated when you run them

Ah I didn't even notice they were dupes. I thought my PR was being validated against Windows ME or something.

@vcsjones

vcsjones commented Feb 14, 2019 •

Copy link
Copy Markdown
Member Author

@bartonjs

OK, results are in. Windows and OpenSSL are not happy with a concatenated private key + certificate, but macOS is. I can either make the tests PlatformSpecific for macOS, or remove the test altogether.

I also tried adding a test for X509Certificate2.GetCertContentType when you give it jibberish since I saw there were no negative tests for it that I could see. I initially wrote it expecting that it would return Unknown since that is what macOS is doing. However Windows and Unix throw. Looking at the Unix source, it looks like it throws intentionally to match Windows' behavior. It seems then that the macOS PAL should be throwing if Unknown is returned.

Thoughts?

@bartonjs

Copy link
Copy Markdown
Member

OK, results are in. Windows and OpenSSL are not happy with a concatenated private key + certificate, but macOS is. I can either make the tests PlatformSpecific for macOS, or remove the test altogether.

It'd be nice if it could also fail on macOS, I guess; but I'm fine with "delete the test" and let it be a weird corner case of success.

I also tried adding a test for X509Certificate2.GetCertContentType when you give it jibberish since I saw there were no negative tests for it that I could see. I initially wrote it expecting that it would return Unknown since that is what macOS is doing. However Windows and Unix throw. Looking at the Unix source, it looks like it throws intentionally to match Windows' behavior. It seems then that the macOS PAL should be throwing if Unknown is returned.

Throwing-to-match sounds good. We could debate if it should return unknown instead of throw, but matching seems nicest.

@vcsjones

Copy link
Copy Markdown
Member Author

/azp run corefx-ci 🤞

@azure-pipelines

Copy link
Copy Markdown

No pipelines are associated with this pull request.

@safern

safern commented Feb 14, 2019

Copy link
Copy Markdown
Member

LOL, the emoji is causing it to not find the pipeline because it takes everything after "run", therefore it thinks the emoji is part of the name.

@vcsjones

Copy link
Copy Markdown
Member Author

/azp run corefx-ci

🤞🤞

@azure-pipelines

Copy link
Copy Markdown

No pipelines are associated with this pull request.

@vcsjones

Copy link
Copy Markdown
Member Author

/azp run corefx-ci

@azure-pipelines

Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@vcsjones

Copy link
Copy Markdown
Member Author

@bartonjs this seems "green" now with feedback changes.

@bartonjs

Copy link
Copy Markdown
Member

The corefx-ci failure seems to have been an infrastructure error after the tests succeeded,.

@bartonjs
bartonjs merged commit ef6e669 into dotnet:master Feb 15, 2019
@vcsjones
vcsjones deleted the fix-29910 branch February 15, 2019 01:53
@stephentoub

Copy link
Copy Markdown
Member

Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new X509Certificate2 fails on macOS for concatenated certificates

5 participants