Merge pull request #196 from mampfes/allow_ssl_verify_false_for_ics

add support to disable ssl certificate verification for ics
This commit is contained in:
Steffen Zimmermann
2022-04-02 11:41:05 +02:00
committed by GitHub
2 changed files with 18 additions and 2 deletions

View File

@@ -132,6 +132,7 @@ class Source:
method="GET",
split_at=None,
version=2,
verify_ssl=True,
):
self._url = url
self._file = file
@@ -144,6 +145,7 @@ class Source:
self._params = params
self._year_field = year_field # replace this field in params with current year
self._method = method # The method to send the params
self._verify_ssl = verify_ssl
def fetch(self):
if self._url is not None:
@@ -182,9 +184,13 @@ class Source:
def fetch_url(self, url, params=None):
# get ics file
if self._method == "GET":
r = requests.get(url, params=params, headers=HEADERS)
r = requests.get(
url, params=params, headers=HEADERS, verify=self._verify_ssl
)
elif self._method == "POST":
r = requests.post(url, data=params, headers=HEADERS)
r = requests.post(
url, data=params, headers=HEADERS, verify=self._verify_ssl
)
else:
raise RuntimeError(
"Error: unknown method to fetch URL, use GET or POST; got {self._method}"

View File

@@ -68,6 +68,7 @@ waste_collection_schedule:
year_field: YEAR_FIELD
split_at: SPLIT_AT
version: 2
verify_ssl: VERIFY_SSL
```
### Configuration Variables
@@ -130,6 +131,15 @@ Selects the underlying ICS file parser:
- version: 1 uses `recurring_ical_events`
- version: 2 uses `icalevents`
**verify_ssl**<br>
*(boolean) (optional, default: True)*
Allows do disable SSL certificate checks in case the HTTPS server of your service provider is misconfigured and therefore doesn't send intermediate certificates. Unlike browsers, python doesn't support automatic fetching of missing intermediates.
Set this option to `False` if you see the following warning in the logs:
`[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate`.
## Examples and Notes
***