From bd0bca69fc6cd4c1328cc6d0283535e49228579e Mon Sep 17 00:00:00 2001 From: pictuga Date: Sat, 3 Oct 2020 19:57:08 +0200 Subject: [PATCH] crawler: ignore ssl via env var --- README.md | 1 + morss/crawler.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ebf1909..c90dad7 100644 --- a/README.md +++ b/README.md @@ -345,6 +345,7 @@ Generic: - `DEBUG=1`: to have some feedback from the script execution. Useful for debugging. +- `IGNORE_SSL=1`: to ignore SSL certs when fetch feeds and articles - `DELAY` sets the browser cache delay, only for HTTP clients - `TIMEOUT` sets the HTTP timeout when fetching rss feeds and articles diff --git a/morss/crawler.py b/morss/crawler.py index f074031..fe1805d 100644 --- a/morss/crawler.py +++ b/morss/crawler.py @@ -53,10 +53,6 @@ except NameError: CACHE_SIZE = int(os.getenv('CACHE_SIZE', 1000)) # max number of items in cache (default: 1k items) CACHE_LIFESPAN = int(os.getenv('CACHE_LIFESPAN', 60)) # how often to auto-clear the cache (default: 1min) -# uncomment the lines below to ignore SSL certs -#import ssl -#ssl._create_default_https_context = ssl._create_unverified_context - MIMETYPE = { 'xml': ['text/xml', 'application/xml', 'application/rss+xml', 'application/rdf+xml', 'application/atom+xml', 'application/xhtml+xml'], @@ -743,6 +739,11 @@ else: default_cache = CappedDict() +if 'IGNORE_SSL' in os.environ: + import ssl + ssl._create_default_https_context = ssl._create_unverified_context + + if __name__ == '__main__': req = adv_get(sys.argv[1] if len(sys.argv) > 1 else 'https://morss.it')