Skip to content

fix cert #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions btrdb/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,20 @@ def __init__(self, addrportstr, apikey=None):
# grpc bundles its own CA certs which will work for all normal SSL
# certificates but will fail for custom CA certs. Allow the user
# to specify a CA bundle via env var to overcome this
ca_bundle = os.getenv("BTRDB_CA_BUNDLE","")
if ca_bundle != "":
env_bundle = os.getenv("BTRDB_CA_BUNDLE", "")
os_certs = "/etc/ssl/certs/ca-certificates.crt"
ca_bundle = env_bundle
if ca_bundle == "":
ca_bundle = os_certs
try:
with open(ca_bundle, "rb") as f:
contents = f.read()
else:
contents = None
except Exception:
if env_bundle != "":
# The user has given us something but we can't use it, we need to make noise
raise Exception("BTRDB_CA_BUNDLE(%s) env is defined but could not read file" % ca_bundle)
else:
contents = None

if apikey is None:
self.channel = grpc.secure_channel(
Expand Down