Skip to content

Commit e803385

Browse files
committed
MINOR: acme: renewal notification over the dpapi sink
Output a sink message when the certificate was renewed by the ACME client. The message is emitted on the "dpapi" sink, and ends by \n\0. Since the message contains this binary character, the right -0 parameter must be used when consulting the sink over the CLI: Example: $ echo "show events dpapi -nw -0" | socat -t9999 /tmp/haproxy.sock - <0>2025-05-19T15:56:23.059755+02:00 acme newcert foobar.pem.rsa\n\0 When used with the master CLI, @@1 should be used instead of @1 in order to keep the connection to the worker. Example: $ echo "@@1 show events dpapi -nw -0" | socat -t9999 /tmp/master.sock - <0>2025-05-19T15:56:23.059755+02:00 acme newcert foobar.pem.rsa\n\0
1 parent 99d6c88 commit e803385

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/acme.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <haproxy/list.h>
3030
#include <haproxy/log.h>
3131
#include <haproxy/pattern.h>
32+
#include <haproxy/sink.h>
3233
#include <haproxy/ssl_ckch.h>
3334
#include <haproxy/ssl_sock.h>
3435
#include <haproxy/ssl_utils.h>
@@ -846,6 +847,8 @@ int acme_update_certificate(struct task *task, struct acme_ctx *ctx, char **errm
846847
int ret = 1;
847848
struct ckch_store *old_ckchs, *new_ckchs;
848849
struct ckch_inst *ckchi;
850+
struct sink *dpapi;
851+
struct ist line[3];
849852

850853
new_ckchs = ctx->store;
851854

@@ -878,6 +881,15 @@ int acme_update_certificate(struct task *task, struct acme_ctx *ctx, char **errm
878881

879882
send_log(NULL, LOG_NOTICE,"acme: %s: Successful update of the certificate.\n", ctx->store->path);
880883

884+
885+
line[0] = ist("acme newcert ");
886+
line[1] = ist(ctx->store->path);
887+
line[2] = ist("\n\0");
888+
889+
dpapi = sink_find("dpapi");
890+
if (dpapi)
891+
sink_write(dpapi, LOG_HEADER_NONE, 0, line, 3);
892+
881893
ctx->store = NULL;
882894

883895
ret = 0;

0 commit comments

Comments
 (0)