Skip to content

Return cached cert first when signing#1838

Merged
woodruffw merged 2 commits into
mainfrom
ft/cached-cert-signing
Jul 26, 2026
Merged

Return cached cert first when signing#1838
woodruffw merged 2 commits into
mainfrom
ft/cached-cert-signing

Conversation

@facutuesca

@facutuesca facutuesca commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

From the discussion in #1729 (comment)

When signing, use the (valid) cached cert even if the identity token is already expired.

Should fix pypa/gh-action-pypi-publish#415 once we make a release and update pypi-attestations with it.

Signed-off-by: Facundo Tuesca <facundo.tuesca@trailofbits.com>
Comment thread test/unit/test_sign.py Outdated
Comment on lines +76 to +85
def test_signer_uses_valid_cached_certificate_with_expired_identity():
cert = pretend.stub(
not_valid_after_utc=datetime.now(timezone.utc) + timedelta(minutes=5)
)

signer = Signer.__new__(Signer)
signer._identity_token = pretend.stub(in_validity_period=lambda: False)
signer._Signer__cached_signing_certificate = cert

assert signer._signing_cert() is cert

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor: any way we can do this with less stubbing? It'd be nice to exercise a real cached flow here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done, see the new test

woodruffw
woodruffw previously approved these changes Jul 25, 2026

@woodruffw woodruffw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @facutuesca!

This seems reasonable to me, only one nitpick about the test.

Signed-off-by: Facundo Tuesca <facundo.tuesca@trailofbits.com>
@woodruffw

Copy link
Copy Markdown
Member

Thank you @facutuesca!

@woodruffw
woodruffw merged commit aa3c7a3 into main Jul 26, 2026
47 checks passed
@woodruffw
woodruffw deleted the ft/cached-cert-signing branch July 26, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attestation error

2 participants