From 0491636666464fdb7eacb1a00869a5aaaf3cfcc4 Mon Sep 17 00:00:00 2001 From: sebthom Date: Mon, 5 Aug 2024 13:47:01 +0200 Subject: [PATCH] fix: SSL: CERTIFICATE_VERIFY_FAILED when running compiled version --- pdm.lock | 12 +++++++++++- pyproject.toml | 1 + src/kleinanzeigen_bot/__init__.py | 8 ++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pdm.lock b/pdm.lock index 8016936..259cb43 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev"] strategy = [] lock_version = "4.5.0" -content_hash = "sha256:0966c51271fe3e6554e908f21ae1f4b128d87ec265f472420a0621b651bc75ca" +content_hash = "sha256:bdc0ef3162d651a6a122298719e21630b9d8d63d571f8269a0189f72fdf622a5" [[metadata.targets]] requires_python = ">=3.10,<3.13" @@ -72,6 +72,16 @@ files = [ {file = "bracex-2.5.tar.gz", hash = "sha256:0725da5045e8d37ea9592ab3614d8b561e22c3c5fde3964699be672e072ab611"}, ] +[[package]] +name = "certifi" +version = "2024.7.4" +requires_python = ">=3.6" +summary = "Python package for providing Mozilla's CA Bundle." +files = [ + {file = "certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90"}, + {file = "certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b"}, +] + [[package]] name = "colorama" version = "0.4.6" diff --git a/pyproject.toml b/pyproject.toml index f735121..fab2d9a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,7 @@ dependencies = [ "psutil", "pywin32; sys_platform == 'win32'", "wcmatch", + "certifi>=2024.7.4", ] [project.urls] diff --git a/src/kleinanzeigen_bot/__init__.py b/src/kleinanzeigen_bot/__init__.py index d95a951..7bff6a5 100644 --- a/src/kleinanzeigen_bot/__init__.py +++ b/src/kleinanzeigen_bot/__init__.py @@ -11,7 +11,7 @@ from datetime import datetime from logging.handlers import RotatingFileHandler from typing import Any, Final -import colorama, nodriver +import certifi, colorama, nodriver from overrides import overrides from ruamel.yaml import YAML from wcmatch import glob @@ -34,6 +34,10 @@ class KleinanzeigenBot(WebScrapingMixin): def __init__(self) -> None: + # workaround for https://github.com/Second-Hand-Friends/kleinanzeigen-bot/issues/295 + # see https://github.com/pyinstaller/pyinstaller/issues/7229#issuecomment-1309383026 + os.environ["SSL_CERT_FILE"] = certifi.where() + super().__init__() self.root_url = "https://www.kleinanzeigen.de" @@ -615,7 +619,7 @@ class KleinanzeigenBot(WebScrapingMixin): # wait for captcha ############################# try: - await self.web_find(By.CSS_SELECTOR,"iframe[name^='a-'][src^='https://www.google.com/recaptcha/api2/anchor?']", timeout=2) + await self.web_find(By.CSS_SELECTOR, "iframe[name^='a-'][src^='https://www.google.com/recaptcha/api2/anchor?']", timeout = 2) LOG.warning("############################################") LOG.warning("# Captcha present! Please solve the captcha.") LOG.warning("############################################")