Add wider support and validation for valid SHA1/256 fingerprints.

Review Request #14925 — Created March 17, 2026 and updated

Information

Review Board
release-7.1.x

Reviewers

CertificateFingerprints.from_string() now supports plain SHA1 and
SHA256 strings (without the semicolons used in fingerprints). These will
be converted into the correct format.

The values are also now validated against regexes. This will first check
the line lengths and then follow up with a pattern match.

Unit tests pass.

Summary ID
Add wider support and validation for valid SHA1/256 fingerprints.
`CertificateFingerprints.from_string()` now supports plain SHA1 and SHA256 strings (without the semicolons used in fingerprints). These will be converted into the correct format. The values are also now validated against regexes. This will first check the line lengths and then follow up with a pattern match.
3591bcfc48229e9dc2e6d64c8267028e03d0b358
Description From Last Updated

A SHA1 hash is 20 bytes, but that corresponds to 40 hex characters. Your test didn't catch this because the …

daviddavid

Leftover debug code.

maubinmaubin

Might be nicer to do length == X and cls.SHA... here instead of nested if statements? Same with the elifs …

maubinmaubin

It might be nice to switch to re.fullmatch() for these, to make it less fragile for future changes. I also …

daviddavid
Checks run (2 succeeded)
flake8 passed.
JSHint passed.
maubin
  1. 
      
  2. reviewboard/certs/cert.py (Diff revision 1)
     
     
    Show all issues

    Leftover debug code.

  3. reviewboard/certs/cert.py (Diff revision 1)
     
     
     
    Show all issues

    Might be nicer to do length == X and cls.SHA... here instead of nested if statements? Same with the elifs below.

  4. 
      
david
  1. 
      
  2. reviewboard/certs/cert.py (Diff revision 1)
     
     
    Show all issues

    A SHA1 hash is 20 bytes, but that corresponds to 40 hex characters. Your test didn't catch this because the invalid character happened to be within the first half of the hash.

  3. reviewboard/certs/cert.py (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Show all issues

    It might be nice to switch to re.fullmatch() for these, to make it less fragile for future changes.

    I also agree with Michelle's comment about combining the conditionals--as long as length is listed first, it won't check the regex match.

    It might also be nice to order these to keep sha1 and sha256 together, instead of going in reverse order by length.

  4.