mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-21 21:01:52 +00:00
Avoid DoS in SSL certificate host matching.
This commit is contained in:
parent
83ec53688d
commit
c676a4c829
2 changed files with 9 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
Features:
|
||||
- checking: Make per-host connection limits configurable.
|
||||
- checking: Avoid DoS in SSL certificate host matcher.
|
||||
|
||||
Changes:
|
||||
- checking: Always use the W3C validator to check HTML or CSS syntax.
|
||||
|
|
|
|||
|
|
@ -118,10 +118,17 @@ class CertificateError(ValueError):
|
|||
pass
|
||||
|
||||
|
||||
def _dnsname_to_pat(dn):
|
||||
def _dnsname_to_pat(dn, max_wildcards=1):
|
||||
"""Convert a DNS certificate name to a hostname matcher."""
|
||||
pats = []
|
||||
for frag in dn.split(r'.'):
|
||||
if frag.count('*') > max_wildcards:
|
||||
# Issue #17980: avoid denials of service by refusing more
|
||||
# than one wildcard per fragment. A survery of established
|
||||
# policy among SSL implementations showed it to be a
|
||||
# reasonable choice.
|
||||
raise CertificateError(
|
||||
"too many wildcards in certificate DNS name: " + repr(dn))
|
||||
if frag == '*':
|
||||
# When '*' is a fragment by itself, it matches a non-empty dotless
|
||||
# fragment.
|
||||
|
|
|
|||
Loading…
Reference in a new issue