Skip to content

Commit 794bbe3

Browse files
authored
Merge pull request #1710 from tosticated/3.1dev
Added check for certificate validity longer than 398 days
2 parents b6bab1e + ad8a52e commit 794bbe3

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* Don't penalize missing trust in rating when CA not in Java store
2222
* Added support for certificates with EdDSA signatures and pubilc keys
2323
* --add-ca can also now be a directory with \*.pem files
24+
* Warning of 398 day limit for certificates issued after 2020/9/1
2425

2526
### Features implemented / improvements in 3.0
2627

CREDITS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Full contribution, see git log.
3939
* Christoph Badura
4040
- NetBSD fixes
4141

42+
* Jim Blankendaal
43+
- maximum certificate lifespan of 398 days
44+
4245
* Frank Breedijk
4346
- Detection of insecure redirects
4447
- JSON and CSV output

testssl.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8353,6 +8353,7 @@ certificate_info() {
83538353
local caa_node="" all_caa="" caa_property_name="" caa_property_value=""
83548354
local response=""
83558355
local yearstart yearend clockstart clockend y m d
8356+
local gt_398=false gt_398warn=false
83568357
local gt_825=false gt_825warn=false
83578358
local badocsp=1
83588359

@@ -9111,6 +9112,26 @@ certificate_info() {
91119112
out "$spaces"
91129113
prln_svrty_medium ">= 5 years is too long"
91139114
fileout "cert_validityPeriod${json_postfix}" "MEDIUM" "$((diffseconds / (3600 * 24) )) days"
9115+
elif [[ $diffseconds -ge $((3600 * 24 * 398 + 1)) ]]; then
9116+
# Also "official" certificates issued from september 1st 2020 (1598918400) aren't supposed
9117+
# to be valid longer than 398 days which is 34387200 in epoch seconds
9118+
gt_398=true
9119+
if "$HAS_OPENBSDDATE"; then
9120+
if [[ 20200901 -le ${yearstart//-/} ]]; then
9121+
gt_398warn=true
9122+
fi
9123+
elif [[ $(parse_date "$startdate" "+%s" $'%F %H:%M') -ge 1598918400 ]]; then
9124+
gt_398warn=true
9125+
fi
9126+
# Now, the verdict, depending on the issuing date
9127+
out "$spaces"
9128+
if "$gt_398warn" && "$gt_398"; then
9129+
prln_svrty_medium "> 398 days issued after 2020/09/01 is too long"
9130+
fileout "cert_validityPeriod${json_postfix}" "MEDIUM" "$((diffseconds / (3600 * 24) )) > 398 days"
9131+
elif "$gt_398"; then
9132+
outln ">= 398 days certificate life time but issued before 2020/09/01"
9133+
fileout "cert_validityPeriod${json_postfix}" "INFO" "$((diffseconds / (3600 * 24) )) =< 398 days"
9134+
fi
91149135
elif [[ $diffseconds -ge $((3600 * 24 * 825 + 1)) ]]; then
91159136
# Also "official" certificates issued from March 1st, 2018 (1517353200) aren't supposed
91169137
# to be valid longer than 825 days which is 1517353200 in epoch seconds

0 commit comments

Comments
 (0)