Skip to content

Commit

Permalink
enable SSL certificate verification by default, add option to disable it
Browse files Browse the repository at this point in the history
  • Loading branch information
GammaC0de committed Jan 26, 2023
1 parent efdaffb commit a9098bd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/pyload/core/config/default.cfg
Expand Up @@ -7,6 +7,7 @@ general - "General":
debug;trace;stack debug_level : "Debug level" = trace
int min_free_space : "Minimum free space in MiB" = 1024
bool folder_per_package : "Create folder for each package" = True
bool ssl_verify : "Peer's SSL certificate verification" = True
permission - "Permissions":
bool change_user : "Change user of running process" = False
str user : "Username for ownership" = user
Expand Down
7 changes: 5 additions & 2 deletions src/pyload/core/network/http/http_request.py
Expand Up @@ -103,7 +103,7 @@ def init_handle(self):
self.c.setopt(pycurl.NOPROGRESS, 1)
if hasattr(pycurl, "AUTOREFERER"):
self.c.setopt(pycurl.AUTOREFERER, 1)
self.c.setopt(pycurl.SSL_VERIFYPEER, 0)
self.c.setopt(pycurl.SSL_VERIFYPEER, 1)
self.c.setopt(pycurl.LOW_SPEED_TIME, 60)
self.c.setopt(pycurl.LOW_SPEED_LIMIT, 5)
if hasattr(pycurl, "USE_SSL"):
Expand All @@ -114,7 +114,7 @@ def init_handle(self):

self.c.setopt(
pycurl.USERAGENT,
b"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36",
b"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0",
)
if pycurl.version_info()[7]:
self.c.setopt(pycurl.ENCODING, b"gzip, deflate")
Expand Down Expand Up @@ -174,6 +174,9 @@ def set_interface(self, options):
if "timeout" in options:
self.c.setopt(pycurl.LOW_SPEED_TIME, int(options["timeout"]))

if "ssl_verify" in options:
self.c.setopt(pycurl.SSL_VERIFYPEER, 1 if options["ssl_verify"] else 0)

def add_cookies(self):
"""
put cookies from curl handle to cj.
Expand Down
1 change: 1 addition & 0 deletions src/pyload/core/network/request_factory.py
Expand Up @@ -112,6 +112,7 @@ def get_options(self):
"interface": self.iface(),
"proxies": self.get_proxies(),
"ipv6": self.pyload.config.get("download", "ipv6"),
"ssl_verify": self.pyload.config.get("general", "ssl_verify"),
}

def update_bucket(self):
Expand Down

0 comments on commit a9098bd

Please sign in to comment.