Skip to content
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

Fix Custom Certificate Handling and Storage in Redis #64

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions imageroot/actions/upload-certificate/23export_certificates
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ result = subprocess.run(
)

subject = result.stdout
domain = subject.split("\n")[1].split("CN=")[1]
domain = {'main': subject.split("\n")[1].split("CN=")[1]}

# save the certificate and key in redis
rdb = agent.redis_connect(privileged=True)
rkey = f'module/{module_id}/certificate/{domain}'
rdb.hset(rkey, mapping={"cert": cert, "key": key, "custom": "true"})
rkey = f'module/{module_id}/certificate/{domain["main"]}'
rdb.hset(rkey, mapping={"cert": data["certFile"], "key": data["keyFile"], "custom": "true"})

# signal the certificate-updated event
event_key = f'module/{module_id}/event/certificate-updated'
Expand Down
5 changes: 5 additions & 0 deletions tests/20_traefik_certificates_api.robot
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ Upload a custom certificate
Should Be Equal As Integers ${response} 1
${response} = Execute Command redis-cli --raw HGET module/traefik1/certificate/test.example.com custom
Should Be Equal As Strings ${response} true
# check if the certificate stored is base64 encoded
${response} = Execute Command command=redis-cli HGET module/traefik1/certificate/test.example.com cert | base64 -d return_stdout=False return_rc=True
Should Be Equal As Integers ${response} 0
${response} = Execute Command command=redis-cli HGET module/traefik1/certificate/test.example.com key | base64 -d return_stdout=False return_rc=True
Should Be Equal As Integers ${response} 0

Delete custom certificate
Run task module/traefik1/delete-certificate {"fqdn": "test.example.com"}
Expand Down
Loading