]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ssl: add a list of crtlist_entry in ckch_store
authorWilliam Lallemand <wlallemand@haproxy.com>
Mon, 30 Mar 2020 16:27:58 +0000 (18:27 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Tue, 31 Mar 2020 10:32:17 +0000 (12:32 +0200)
When updating a ckch_store we may want to update its pointer in the
crtlist_entry which use it. To do this, we need the list of the entries
using the store.

include/types/ssl_sock.h
src/ssl_sock.c

index 2f366fc3556aa410c677131870125e426222f69d..9f3e93a6d088b2b62b4da3fd134b0e6eb183fcef 100644 (file)
@@ -123,6 +123,7 @@ struct ckch_store {
        struct cert_key_and_chain *ckch;
        unsigned int multi:1;  /* is it a multi-cert bundle ? */
        struct list ckch_inst; /* list of ckch_inst which uses this ckch_node */
+       struct list crtlist_entry; /* list of entries which use this store */
        struct ebmb_node node;
        char path[0];
 };
@@ -168,6 +169,7 @@ struct crtlist_entry {
        char **filters;
        struct list ckch_inst; /* list of instances of this entry, there is 1 ckch_inst per instance of the crt-list */
        struct list by_crtlist; /* ordered entries */
+       struct list by_ckch_store; /* linked in ckch_store list of crtlist_entries */
        struct ebpt_node node; /* key is a ptr to a ckch_store */
 };
 
index f799ca8af0b56a260ec925c14033d66aaa3198d0..39e63151e4bf8f85f36da03209a11906bd99af31 100644 (file)
@@ -3781,6 +3781,7 @@ static struct ckch_store *ckchs_dup(const struct ckch_store *src)
        memcpy(dst->path, src->path, pathlen + 1);
        dst->multi = src->multi;
        LIST_INIT(&dst->ckch_inst);
+       LIST_INIT(&dst->crtlist_entry);
 
        dst->ckch = calloc((src->multi ? SSL_SOCK_NUM_KEYTYPES : 1), sizeof(*dst->ckch));
        if (!dst->ckch)
@@ -3845,6 +3846,7 @@ static struct ckch_store *ckchs_load_cert_file(char *path, int multi, char **err
        }
 
        LIST_INIT(&ckchs->ckch_inst);
+       LIST_INIT(&ckchs->crtlist_entry);
 
        if (!multi) {
 
@@ -4643,6 +4645,7 @@ static int crtlist_load_cert_dir(char *path, struct bind_conf *bind_conf, struct
                                                goto end;
                                        }
                                        entry->node.key = ckchs;
+                                       LIST_ADDQ(&ckchs->crtlist_entry, &entry->by_ckch_store);
                                        LIST_ADDQ(&dir->ord_entries, &entry->by_crtlist);
                                        ebpt_insert(&dir->entries, &entry->node);
 
@@ -4662,6 +4665,7 @@ static int crtlist_load_cert_dir(char *path, struct bind_conf *bind_conf, struct
                                goto end;
                        }
                        entry->node.key = ckchs;
+                       LIST_ADDQ(&ckchs->crtlist_entry, &entry->by_ckch_store);
                        LIST_ADDQ(&dir->ord_entries, &entry->by_crtlist);
                        ebpt_insert(&dir->entries, &entry->node);
 
@@ -4860,6 +4864,7 @@ static int crtlist_parse_file(char *file, struct bind_conf *bind_conf, struct pr
                entry->fcount = arg - cur_arg - 1;
                ebpt_insert(&newlist->entries, &entry->node);
                LIST_ADDQ(&newlist->ord_entries, &entry->by_crtlist);
+               LIST_ADDQ(&ckchs->crtlist_entry, &entry->by_ckch_store);
        }
        if (cfgerr & ERR_CODE)
                goto error;
@@ -12023,6 +12028,7 @@ static int cli_parse_new_cert(char **args, char *payload, struct appctx *appctx,
        }
        /* we won't create any instance */
        LIST_INIT(&store->ckch_inst);
+       LIST_INIT(&store->crtlist_entry);
 
        /* we won't support multi-certificate bundle here */
        store->multi = 0;