Skip to content

Commit

Permalink
Concatenate SSL CAs before encoding
Browse files Browse the repository at this point in the history
Otherwise you can end up with `==` padding in the middle of the encoded secret data, which is invalid base64.
  • Loading branch information
manics committed Mar 28, 2024
1 parent 1174a00 commit 2b95b13
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions kubespawner/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,16 +1014,11 @@ def make_secret(
encoded = base64.b64encode(file.read().encode("utf-8"))
secret.data['ssl.crt'] = encoded.decode("utf-8")

with open(cert_paths['cafile']) as file:
encoded = base64.b64encode(file.read().encode("utf-8"))
with open(cert_paths['cafile']) as ca_file, open(hub_ca) as hub_ca_file:
cas = ca_file.read().strip("\n") + "\n" + hub_ca_file.read()
encoded = base64.b64encode(cas.encode("utf-8"))
secret.data["notebooks-ca_trust.crt"] = encoded.decode("utf-8")

with open(hub_ca) as file:
encoded = base64.b64encode(file.read().encode("utf-8"))
secret.data["notebooks-ca_trust.crt"] = secret.data[
"notebooks-ca_trust.crt"
] + encoded.decode("utf-8")

return secret


Expand Down

0 comments on commit 2b95b13

Please sign in to comment.