Skip to content

Commit 31b3cb1

Browse files
fixes Let's Encrypt cert issue (#9)
1 parent 91156c2 commit 31b3cb1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

btrdb/conn.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,20 @@ def __init__(self, addrportstr, apikey=None):
6565
# grpc bundles its own CA certs which will work for all normal SSL
6666
# certificates but will fail for custom CA certs. Allow the user
6767
# to specify a CA bundle via env var to overcome this
68-
ca_bundle = os.getenv("BTRDB_CA_BUNDLE","")
69-
if ca_bundle != "":
68+
env_bundle = os.getenv("BTRDB_CA_BUNDLE", "")
69+
os_certs = "/etc/ssl/certs/ca-certificates.crt"
70+
ca_bundle = env_bundle
71+
if ca_bundle == "":
72+
ca_bundle = os_certs
73+
try:
7074
with open(ca_bundle, "rb") as f:
7175
contents = f.read()
72-
else:
73-
contents = None
76+
except Exception:
77+
if env_bundle != "":
78+
# The user has given us something but we can't use it, we need to make noise
79+
raise Exception("BTRDB_CA_BUNDLE(%s) env is defined but could not read file" % ca_bundle)
80+
else:
81+
contents = None
7482

7583
if apikey is None:
7684
self.channel = grpc.secure_channel(

0 commit comments

Comments
 (0)