Skip to content

Commit

Permalink
Fix: SSL error in bundled/frozen application
Browse files Browse the repository at this point in the history
Depending on the packaged libcrypto on Unix systems the cacerts default
paths might differ
(see: pyinstaller/pyinstaller#7229).
To get an actually portable solution we use certifi's bundled cacerts
(CAs approved by Mozilla).
Since that is not what users may want and the bundled cacerts might
be outdated we added a config option for this, so a user can
set the environment variable `SSL_CERT_FILE` themselves
  • Loading branch information
nilfoer committed Feb 24, 2024
1 parent 3085b20 commit d8a3a2c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
17 changes: 17 additions & 0 deletions gwaripper/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging

import praw
import certifi

from typing import List, Optional

Expand Down Expand Up @@ -274,6 +275,7 @@ def main():
args = parser.parse_args()

if root_dir:
setup_cacerts()

# set selected ignore-banned option in config
if args.ignore_banned:
Expand All @@ -294,6 +296,21 @@ def main():
"\"C:\\absolute\\path\" to specify where the files will be downloaded to")


def setup_cacerts() -> None:
# depending on the packaged libcrypto on Unix systems the cacerts default
# paths might differ
# (see: https://github.com/pyinstaller/pyinstaller/issues/7229)
# to get an actually portable solution we use certifi's bundled cacerts
# (CAs approved by Mozilla)
# since that is not what users may want and the bundled cacerts might
# be outdated we added a config option for this, so a user can
# set the environment variable `SSL_CERT_FILE` themselve
import config
if config.config["Settings"].get("set_ssl_cert_file", True):
cacerts_path = certifi.where()
os.environ["SSL_CERT_FILE"] = cacerts_path


def download_all_links(urls: List[str], args: argparse.Namespace) -> None:
with GWARipper(
download_duplicates=args.download_duplicates,
Expand Down
1 change: 1 addition & 0 deletions gwaripper/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"set_missing_reddit": "True",
"only_one_mirror": "False",
"host_priority": "0,5,4",
"set_ssl_cert_file": "True",
},
"Time": {
"last_db_bu": str(time.time()),
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ praw>=7.5,<8
flask>=2.2.5,<4
music-tag>=0.4,<0.5
typing-extensions>=3.7.4
certifi
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setuptools.setup(
name="GWARipper",
version="0.7.2",
version="0.8.0",
description="A script that downloads audio files from the gonewildaudio subreddit.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand All @@ -29,11 +29,12 @@
license="MIT",
keywords="script reddit gonewildaudio download scraping",
packages=setuptools.find_packages(exclude=['tests*']),
python_requires='>=3.6',
python_requires='>=3.8',
install_requires=["pyperclip>=1.5.25,<=1.7.0", "praw>=7.5,<8",
"beautifulsoup4>=4.5.3,<=4.6.3",
"flask>=3,<4",
"music-tag>=0.4,<0.5",
"certifi",
# 3.7.2 would be enough but mypy 0.782 uses >=3.7.4
"typing-extensions>=3.7.4"],

Expand Down

0 comments on commit d8a3a2c

Please sign in to comment.