mk-ca-bundle.pl: make generated timestamps deterministic#20528
mk-ca-bundle.pl: make generated timestamps deterministic#20528vszakats wants to merge 17 commits intocurl:masterfrom
Conversation
|
It struck me that it could be an idea to change the default behavior to first check which ref is the latest in the particular tree to check, and then get that ref. That would make us always get certs by ref and thus also get a stable date. Does it make sense? |
|
It'd be a useful feature to detect upstream updates. Though for a deterministic I'm not sure how to detect the latest commit for a specific file in a specific |
Absolutely, and I'm not arguing about that. I was just thinking that by switching to always getting a ref, we would get a date for all fetches. The difference would only be which ref we get. I'll take a look as well. |
Meh, I can't figure it out but the API docs seems to imply it should be possible. |
|
This seems to be working at first sight: curl 'https://api.github.com/repos/mozilla-firefox/firefox/commits?path=/security/nss/lib/ckfw/builtins/certdata.txt&sha=release' |
|
So with |
|
I learned jq has a "first" builtin which makes it even simpler looking: |
|
I'm trying to figure out what would be a nice way to integrate it into c4w, psl is similar, but we can avoid the GH API call by downloading the Version detection can be done with that one curl call, and this already |
|
I ended up solving it within c4w, by reusing the existing bump/download For curl-container it'd still be useful to implement some of this within In c4w, the slight downside is departing from the curl website, which is The direct way also has the limitation that it lacks support for verifying |
|
Actually another benefit of implementing some of this logic within |
I think it is also nicer to get the actual date of the commit/remote file into the generated |
|
Ended up keeping it simple by just making timestamps |
…imestamp Add `-r <commit ref or hash>` option to retrieve a specific revision of `certdata.txt`. In this mode, also retrieve the commit timestamp for that revision, and use that in `ca-bundle.crt` for deterministic output. E.g.: ``` $ ./mk-ca-bundle.pl -r 397c3187280dfa84ce9da56a9944d945bf73977d ```
25d36ca to
7166727
Compare
|
@vszakats a downside with this approach has turned up: the date in the mozilla file is potentially a long time from the current date, and we no longer get the download time stamp in there. The caextract web page now says "This bundle was generated at Feb 11 2026" for the certificate that was new in the bundle on March 19! I've updated it to say "This bundle was updated by Mozilla at ..." but still. Users on the caextract page did not get this bundle until March 19. I think we should show the latter date, not the date from one month before it was accessible... |
|
I saw that, yes. We can just revert this (curl-for-win doesn't rely on this), or move it behind an option? I was surprised by such time difference, given that the script looks for the commit date. Does it mean Mozilla pushes to the public repo not in real-time (or close to), but only once a month / occasionally? (But even a small diff between publish and detection by curl.se may cause a different date in the archived bundle filename and the reproducible date within it) edit: the only line to keep unconditionally is utime() at the end. |
Behind new option `-r` for reproducible output. Mozilla may push to its repo much later than the commit date, which can be a source of confusion when using the reproducible timestamp (which is determined by the commit date) by default. Also: drop a stray variable assigned, but not used. Reported-by: Daniel Stenberg Bug: curl#20528 (comment) Follow-up to ca92e20 curl#20528
Behind new option `-r` for reproducible output. Mozilla may push to its repo much later than the commit date, which can be a source of confusion when using the reproducible timestamp (which is determined by the commit date) by default. Example: https://curl.se/ca/cacert-2026-03-19.pem Also: drop a stray variable assigned, but not used. Reported-by: Daniel Stenberg Bug: curl#20528 (comment) Follow-up to ca92e20 curl#20528
Behind new option `-r`, for reproducible output. Mozilla may push to its repo much later than the commit date, which can be a source of confusion when using the reproducible timestamp (which is determined by the commit date) by default. Example: https://curl.se/ca/cacert-2026-03-19.pem Also: drop a stray variable assigned, but not used. Reported-by: Daniel Stenberg Bug: curl#20528 (comment) Follow-up to ca92e20 curl#20528
Behind new option `-r`, for reproducible output. Mozilla may push to its repo much later than the commit date, which can be a source of confusion when using the reproducible timestamp (which is determined by the commit date) by default. Example: https://curl.se/ca/cacert-2026-03-19.pem Also: drop a stray variable assigned, but not used. Reported-by: Daniel Stenberg Bug: curl#20528 (comment) Follow-up to ca92e20 curl#20528
Mozilla may push to its repo much later than the commit date, which can be a source of confusion when using the reproducible timestamp (which is determined by the commit date) by default. Example: https://curl.se/ca/cacert-2026-03-19.pem vs. https://github.com/mozilla-firefox/firefox/commits/1a84aee6387d2f9c9531c655edeea4a80aa0fcfa/security/nss/lib/ckfw/builtins/certdata.txt This feature had no actual user (or a planned one) from within curl at the moment, and not requested by curl users. curl-for-win does this on its own, which is the more practical way there since everything (not just the CA bundle) needs to be reproducible anyway. I surmise this may be true for most if not all reproducible use-cases. Another limitation was that it could bump into GitHub's rate limiting, needing further updates. Also: code had some unintented leftovers. Reported-by: Daniel Stenberg Bug: #20528 (comment) Follow-up to ca92e20 #20528 Closes #21116
Follow-up to 351e4f9 curl#21116 Follow-up to ca92e20 curl#20528
With default invocation, make generated file timestamps deterministic
by looking up (via the GitHub API) the last commit that modified
certdata.txt, along with its commit timestamp.Also:
certdata.txtfrom.ca-bundle.crttimestamp matchcertdata.txt's.-r? [NO, but also skip adding-rfor now]