-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish certificate-changed event when a custom TLS certificate has been uploaded.
- Loading branch information
1 parent
d484a05
commit f4cf443
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
imageroot/actions/upload-certificate/30certificate_changed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# Copyright (C) 2025 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
import os | ||
import json | ||
import agent | ||
import sys | ||
import base64 | ||
import cert_helpers | ||
|
||
|
||
def main(): | ||
request = json.load(sys.stdin) | ||
bcert = base64.b64decode(request["certFile"]) | ||
changed_dns_names = cert_helpers.extract_certified_names(bcert) | ||
notify_certificate_changed_event(changed_dns_names) | ||
|
||
def notify_certificate_changed_event(changed_dns_names): | ||
rdb = agent.redis_connect(privileged=True) | ||
rdb.publish(f"{os.environ['AGENT_ID']}/event/certificate-changed", json.dumps({ | ||
"node_id": int(os.environ['NODE_ID']), | ||
"module_id": os.environ['MODULE_ID'], | ||
"names": list(changed_dns_names), | ||
})) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters