Skip to content

Commit 6937fa1

Browse files
Verify that timestamp is before the signing certificate expiry (#42)
* _verify: Verify that integrated time falls between certificate validity window * _verify: Use UTC timestamp * _verify: tweak notAfter verification Co-authored-by: William Woodruff <[email protected]>
1 parent 594efa5 commit 6937fa1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sigstore/_verify.py

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import base64
6+
import datetime
67
import hashlib
78
from importlib import resources
89
from typing import Optional, TextIO, cast
@@ -74,6 +75,8 @@ def verify(
7475
#
7576
# 4) Verify the inclusion proof supplied by Rekor for this artifact
7677
# 5) Verify the Signed Entry Timestamp (SET) supplied by Rekor for this artifact
78+
# 6) Verify that the signing certificate was valid at the time of signing by comparing the
79+
# expiry against the integrated timestamp
7780

7881
# 1) Verify that the signing certificate is signed by the root certificate and that the signing
7982
# certificate was valid at the time of signing.
@@ -157,6 +160,18 @@ def verify(
157160
output(f"Failed to validate Rekor entry's SET: {inval_set}")
158161
continue
159162

163+
# 6) Verify that the signing certificate was valid at the time of signing
164+
integrated_time = datetime.datetime.utcfromtimestamp(entry.integrated_time)
165+
if (
166+
integrated_time < cert.not_valid_before
167+
or integrated_time >= cert.not_valid_after
168+
):
169+
# No need to log anything here.
170+
#
171+
# If an artifact has been signed multiple times, this will happen so it's not really an
172+
# error case.
173+
continue
174+
160175
valid_sig_exists = True
161176

162177
if not valid_sig_exists:

0 commit comments

Comments
 (0)