]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ssl: reach a ckch_store from a sni_ctx
authorWilliam Lallemand <wlallemand@haproxy.com>
Thu, 5 Mar 2020 09:17:47 +0000 (10:17 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Thu, 5 Mar 2020 10:28:42 +0000 (11:28 +0100)
It was only possible to go down from the ckch_store to the sni_ctx but
not to go up from the sni_ctx to the ckch_store.

To allow that, 2 pointers were added:

- a ckch_inst pointer in the struct sni_ctx
- a ckckh_store pointer in the struct ckch_inst

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

index bb64e49723411bb3f9250855ab6d876e295f08de..9155b6d344841425fef0ba781e7475968f8972e8 100644 (file)
@@ -42,6 +42,7 @@ struct sni_ctx {
        struct pkey_info kinfo;   /* pkey info */
        struct ssl_bind_conf *conf; /* ssl "bind" conf for the certificate */
        struct list by_ckch_inst; /* chained in ckch_inst's list of sni_ctx */
+       struct ckch_inst *ckch_inst; /* instance used to create this sni_ctx */
        struct ebmb_node name;    /* node holding the servername value */
 };
 
@@ -126,6 +127,7 @@ struct ckch_store {
 struct ckch_inst {
        struct bind_conf *bind_conf; /* pointer to the bind_conf that uses this ckch_inst */
        struct ssl_bind_conf *ssl_conf; /* pointer to the ssl_conf which is used by every sni_ctx of this inst */
+       struct ckch_store *ckch_store; /* pointer to the store used to generate this inst */
        int is_default;      /* This instance is used as the default ctx for this bind_conf */
        struct list sni_ctx; /* list of sni_ctx using this ckch_inst */
        struct list by_ckchs; /* chained in ckch_store's list of ckch_inst */
index 86894cb4401d192cec4c255116e413be897784d6..df15b77c192873f58adff6b20cdb79fe0543b27f 100644 (file)
@@ -2949,6 +2949,7 @@ static int ckch_inst_add_cert_sni(SSL_CTX *ctx, struct ckch_inst *ckch_inst,
                sc->neg = neg;
                sc->wild = wild;
                sc->name.node.leaf_p = NULL;
+               sc->ckch_inst = ckch_inst;
                LIST_ADDQ(&ckch_inst->sni_ctx, &sc->by_ckch_inst);
        }
        return order;
@@ -4186,6 +4187,7 @@ static int ckch_inst_new_load_multi_store(const char *path, struct ckch_store *c
 
        ckch_inst->bind_conf = bind_conf;
        ckch_inst->ssl_conf = ssl_conf;
+       ckch_inst->ckch_store = ckchs;
 end:
 
        if (names)
@@ -4374,6 +4376,7 @@ static int ckch_inst_new_load_store(const char *path, struct ckch_store *ckchs,
        /* everything succeed, the ckch instance can be used */
        ckch_inst->bind_conf = bind_conf;
        ckch_inst->ssl_conf = ssl_conf;
+       ckch_inst->ckch_store = ckchs;
 
        *ckchi = ckch_inst;
        return errcode;