Skip to content

crypto/x509: come up with better solution for testing platform verifiers #52108

Open
@rolandshoemaker

Description

@rolandshoemaker

As evidenced by #52094 and #51599, there are issues with relying on third-party services for testing the platform verifier implementations. Ideally we'd run these tests entirely locally, but this requires mutating the trust store on the systems being tested.

While we absolutely cannot start inserting arbitrary certificates into the trust stores of developers, it may be reasonable to do this on the trybots (although there will still be some gaps here, since user added roots are always going to be treated somewhat differently than roots the system chooses to trust.)

We should still have some kind of local testing that doesn't rely on trust store mutation though, perhaps just retaining the existing badssl.com based tests but gating them behind a flag?

Activity

added
NeedsFixThe path to resolution is known, but the work has not been done.
on Apr 1, 2022
gopherbot

gopherbot commented on Apr 2, 2022

@gopherbot
Contributor

Change https://go.dev/cl/397694 mentions this issue: crypto/x509: local platform verifier tests on trybots

gopherbot

gopherbot commented on May 12, 2022

@gopherbot
Contributor

Change https://go.dev/cl/405914 mentions this issue: crypto/x509: attempt to prime windows root pool before hybrid test

bcmills

bcmills commented on Jun 14, 2022

@bcmills
Contributor

2022-06-06T18:37:38-fc97075/windows-amd64-longtest has another failure due to badssl.com having a cert that is bad in the wrong kind of way:

--- FAIL: TestPlatformVerifier (15.19s)
    --- FAIL: TestPlatformVerifier/wrong_host_for_leaf (15.11s)
        root_windows_test.go:109: unexpected verification error: got "x509: certificate has expired or is not yet valid: ", want "x509: certificate is valid for *.badssl.com, badssl.com, not wrong.host.badssl.com"
FAIL
FAIL	crypto/x509	32.031s
added this to the Backlog milestone on Aug 20, 2022
rolandshoemaker

rolandshoemaker commented on Dec 21, 2022

@rolandshoemaker
MemberAuthor

The least worst option I can think of: we insert a static certificate into the builder images for macos and windows, and use it to sign local certificates. For testing on local systems, we provide a very scary flag the user can pass that will generate an ephemeral key/cert pair and attempt to insert it into the trust store for the duration of the testing, removing it when done.

This should get us the best of both worlds, with only minor pain.

rolandshoemaker

rolandshoemaker commented on Apr 17, 2023

@rolandshoemaker
MemberAuthor

Plan is: basically above. We'll generate a highly constrained root, which will be used for testing. Rather than a flag that lets the user insert it into their own pool, we'll simply add it to the tree and allow users to insert it into their own trust pool if they wish.

We'll add a wrapper to the platform tests which decide whether or not to run them based on the detectable presence of the constraint root, this way they'll run on developers systems who want to test them, and it'll require at least some knowledge of trust stores in order to add it (rather than simply passing a flag and not really knowing what you're getting yourself into).

I'll implement the sniffing + tests etc first, and once that has landed and we have a root in the tree, we'll pass this on to the release team to add to the builder images.

gopherbot

gopherbot commented on Apr 25, 2023

@gopherbot
Contributor

Change https://go.dev/cl/488855 mentions this issue: crypto/x509: use synthetic root for platform testing

25 remaining items

rolandshoemaker

rolandshoemaker commented on Dec 11, 2023

@rolandshoemaker
MemberAuthor

Based on the LUCI results, I am under the impression the test root has only been added to the TryBot builders, but not the LUCI builders (which show the skip message because the test root cannot be found). Is there a timeline for adding them to the LUCI ones as well?

I think we could probably can delete the old tests now, but if we are only running the LUCI builders then these tests wont be exercised at all, which is probably not ideal.

cc @cagedmantis

dmitshur

dmitshur commented on Dec 22, 2023

@dmitshur
Member

As an update, test results here show the new test is running (not skipping) and passing on the recent windows/arm64 LUCI builder (#64587).

added
Buildersx/build issues (builders, bots, dashboards)
on Dec 22, 2023
modified the milestones: Go1.22, Go1.23 on Jan 25, 2024
gopherbot

gopherbot commented on May 16, 2024

@gopherbot
Contributor

Change https://go.dev/cl/586215 mentions this issue: [release-branch.go1.21] crypto/x509: remove TestPlatformVerifierLegacy tests

gopherbot

gopherbot commented on May 16, 2024

@gopherbot
Contributor

Change https://go.dev/cl/586235 mentions this issue: [release-branch.go1.22] crypto/x509: remove TestPlatformVerifierLegacy tests

modified the milestones: Go1.23, Go1.24 on Aug 13, 2024
modified the milestones: Go1.24, Go1.25 on Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Buildersx/build issues (builders, bots, dashboards)NeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

Status

Planned

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @cagedmantis@dmitshur@odeke-em@rolandshoemaker@bcmills

      Issue actions

        crypto/x509: come up with better solution for testing platform verifiers · Issue #52108 · golang/go