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

schannel: use CERT_CONTEXT's pbCertEncoded to determine chain order #11632

Closed
wants to merge 4 commits into from

Conversation

nmoinvaz
Copy link
Contributor

@nmoinvaz nmoinvaz commented Aug 8, 2023

CERT_CONTEXT from SECPKG_ATTR_REMOTE_CERT_CONTEXT contains end-entity/server certificate in pbCertEncoded. We can use this pointer to determine the order of certificates when enumerating hCertStore using CertEnumCertificatesInStore.

I tested this method of determining enumeration order on Windows 10 and Windows 11.

For background info see PR #9706 and this comment.

@github-actions github-actions bot added the tests label Aug 8, 2023
@nmoinvaz nmoinvaz force-pushed the nathan/schannel-cert-info-order branch from b16426f to 40555a3 Compare August 8, 2023 20:45
@nmoinvaz nmoinvaz changed the title schannel: Use CERT_CONTEXT's pbCertEncoded to determine chain order schannel: use CERT_CONTEXT's pbCertEncoded to determine chain order Aug 8, 2023
@nmoinvaz nmoinvaz force-pushed the nathan/schannel-cert-info-order branch 2 times, most recently from cebc66b to b56b6d2 Compare August 8, 2023 21:38
@bagder bagder added TLS Windows Windows-specific labels Aug 8, 2023
@jay
Copy link
Member

jay commented Aug 9, 2023

The xml test file needs to be in LF format, except for the request responses (data,datacheck,protocol etc) which are CRLF. It seems I can't do this for you probably because your PR comes from an organization. The line endings should look like this for example (screenshot from test3101):

Capture

ci job for example this one:
2023-08-08T22:56:20.0589134Z test 3102...[Verify certificate chain order with simple HTTPS GET
2023-08-08T22:56:20.0596335Z ]
2023-08-08T22:56:20.0616091Z 3102: IGNORED: The tool set in the test case for this: 'lib3102
2023-08-08T22:56:20.0616933Z .exe' does not exist

@nmoinvaz nmoinvaz force-pushed the nathan/schannel-cert-info-order branch from b56b6d2 to b1db7e5 Compare August 9, 2023 15:37
@nmoinvaz
Copy link
Contributor Author

nmoinvaz commented Aug 9, 2023

Thanks, I think I got it now:

image

@nmoinvaz nmoinvaz force-pushed the nathan/schannel-cert-info-order branch 3 times, most recently from 4c17fda to 006344f Compare August 10, 2023 06:16
@bagder bagder requested a review from jay August 14, 2023 07:16
@jay
Copy link
Member

jay commented Aug 19, 2023

It looks like the test is not running in Windows CI jobs but it's running in Linux jobs. I don't see anything obvious that could be causing that.

@nmoinvaz
Copy link
Contributor Author

nmoinvaz commented Aug 19, 2023

Which Windows CI jobs are you looking at? The ones I am seeing from AppVeyor only have a short build log. The only thing I can think of is maybe it doesn't like this:

# SSL with libraries supporting CURLOPT_CERTINFO
<features>
SSL
!bearssl
!mbedtls
!rustls
!wolfssl
</features>

Perhaps I need to specifically include openssl and schannel in that list..

@jay
Copy link
Member

jay commented Aug 23, 2023

It looks like the test is not running in Windows CI jobs but it's running in Linux jobs.

It looks as though tests that use SSL are not running in Windows CI jobs because of an stunnel bug. mback2k/curl-docker-winbuildenv#2. I still do not know why some of the test results do not show a skipped test message for this test, which is what should happen if the test is skipped. It may be because of the way stunnel fails. The installation is valid and the file is executable but its version information can't be parsed. There's logic that lists SSL as a supported test type but then none of those tests actually run because stunnel technically isn't considered valid if the version info parsing fails.

edit: two more bugs found see #11721 and #11722

@nmoinvaz
Copy link
Contributor Author

nmoinvaz commented Aug 23, 2023

Thanks for diving in and looking at it. I reviewed those two PRs, and I can rebase after they are merged in.

@nmoinvaz nmoinvaz force-pushed the nathan/schannel-cert-info-order branch from 006344f to 452f9fe Compare August 28, 2023 22:11
@nmoinvaz
Copy link
Contributor Author

Rebased

CERT_CONTEXT from SECPKG_ATTR_REMOTE_CERT_CONTEXT contains end-entity/server
certificate in pbCertEncoded. We can use this pointer to determine the order
of certificates when enumerating hCertStore using CertEnumCertificatesInStore.
Uses lib3102 tool. Test data is based on test560.
@nmoinvaz nmoinvaz force-pushed the nathan/schannel-cert-info-order branch from 452f9fe to 243ea04 Compare September 1, 2023 01:53
@nmoinvaz
Copy link
Contributor Author

nmoinvaz commented Sep 1, 2023

Rebased again.

@jay jay closed this in f6700c7 Sep 8, 2023
@jay
Copy link
Member

jay commented Sep 8, 2023

Thanks

ptitSeb pushed a commit to wasix-org/curl that referenced this pull request Sep 25, 2023
- Use CERT_CONTEXT's pbCertEncoded to determine chain order.

CERT_CONTEXT from SECPKG_ATTR_REMOTE_CERT_CONTEXT contains
end-entity/server certificate in pbCertEncoded. We can use this pointer
to determine the order of certificates when enumerating hCertStore using
CertEnumCertificatesInStore.

This change is to help ensure that the ordering of the certificate chain
requested by the user via CURLINFO_CERTINFO has the same ordering on all
versions of Windows.

Prior to this change Schannel certificate order was reversed in 8986df8
but that was later reverted in f540a39 when it was discovered that
Windows 11 22H2 does the reversal on its own.

Ref: curl#9706

Closes curl#11632
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests TLS Windows Windows-specific
Development

Successfully merging this pull request may close these issues.

None yet

3 participants