diff --git a/pshtt/pshtt.py b/pshtt/pshtt.py index a16debcb..71b82e16 100644 --- a/pshtt/pshtt.py +++ b/pshtt/pshtt.py @@ -1199,16 +1199,23 @@ def is_missing_intermediate_cert(domain): def is_hsts(domain): """ - Domain has HSTS if its canonical HTTPS endpoint has HSTS. + Domain has HSTS if both https and httpswww endpoints have HSTS when live. """ - canonical, https, httpswww = domain.canonical, domain.https, domain.httpswww + https, httpswww = domain.https, domain.httpswww - if canonical.host == "www": - canonical_https = httpswww - else: - canonical_https = https + if not https.live and not httpswww.live: + return None + + hsts = None + if https.live and (https.hsts is not None): + hsts = https.hsts + if httpswww.live and (httpswww.hsts is not None): + if hsts is None: + hsts = httpswww.hsts + else: + hsts &= httpswww.hsts - return canonical_https.hsts + return hsts def hsts_header(domain):