MINOR: ssl: add a list of crtlist_entry in ckch_store

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.
This commit is contained in:
William Lallemand 2020-03-30 18:27:58 +02:00 committed by William Lallemand
parent 09bd5a0787
commit 23d61c00b9
2 changed files with 8 additions and 0 deletions

View 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 */
};

View 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;