Skip to content

Commit

Permalink
Merge pull request #2278 from half-duplex/no-ca-hunt
Browse files Browse the repository at this point in the history
config: don't manually hunt for CA paths
  • Loading branch information
dgw authored May 21, 2022
2 parents c560c6d + eb7d16b commit 984e1b9
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions sopel/config/core_section.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from __future__ import annotations

import os.path

from sopel.config.types import (
BooleanAttribute,
ChoiceAttribute,
Expand All @@ -23,29 +21,6 @@
"""Default URL schemes allowed for URLs."""


def _find_certs():
"""Find the TLS root CA store.
:returns: path to CA store file
:rtype: str
"""
# check if the root CA store is at a known location
locations = [
'/etc/pki/tls/cert.pem', # best first guess
'/etc/ssl/certs/ca-certificates.crt', # Debian
'/etc/ssl/cert.pem', # FreeBSD base OpenSSL
'/usr/local/openssl/cert.pem', # FreeBSD userland OpenSSL
'/etc/pki/tls/certs/ca-bundle.crt', # RHEL 6 / Fedora
'/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem', # RHEL 7 / CentOS
'/etc/pki/tls/cacert.pem', # OpenELEC
'/etc/ssl/ca-bundle.pem', # OpenSUSE
]
for certs in locations:
if os.path.isfile(certs):
return certs
return None


def configure(config):
"""Interactively configure the bot's ``[core]`` config section.
Expand Down Expand Up @@ -228,17 +203,16 @@ class CoreSection(StaticSection):
"""

ca_certs = FilenameAttribute('ca_certs', default=_find_certs())
"""The path to the CA certs ``.pem`` file.
ca_certs = FilenameAttribute('ca_certs')
"""The path to the CA certs ``PEM`` file.
Example:
.. code-block:: ini
ca_certs = /etc/ssl/certs/ca-certificates.crt
If not specified, Sopel will try to find the certificate trust store
itself from a set of known locations.
If not specified, the system default will be used.
If the given value is not an absolute path, it will be interpreted relative
to the directory containing the config file with which Sopel was started.
Expand Down

0 comments on commit 984e1b9

Please sign in to comment.