Commit 64fcac48 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

shrpx: Fix bug in building certificate lookup tree

parent c8167234
......@@ -587,7 +587,11 @@ void cert_lookup_tree_add_cert(CertLookupTree *lt, CertNode *node,
cn->str[i] == hostname[j]; --i, --j);
if(i == cn->last) {
if(j == -1) {
if(cn->ssl_ctx) {
// same hostname, we don't overwrite exiting ssl_ctx
} else {
cn->ssl_ctx = ssl_ctx;
}
} else {
// The existing hostname is a suffix of this hostname.
// Continue matching at potion j.
......
......@@ -96,9 +96,10 @@ void test_shrpx_ssl_create_lookup_tree(void)
}
SSL_CTX *ctxs2[] = {SSL_CTX_new(TLSv1_method()),
SSL_CTX_new(TLSv1_method()),
SSL_CTX_new(TLSv1_method()),
SSL_CTX_new(TLSv1_method())};
const char *names[] = { "rab", "zab", "zzub" };
const char *names[] = { "rab", "zab", "zzub", "ab" };
num = sizeof(ctxs2)/sizeof(ctxs2[0]);
tree = ssl::cert_lookup_tree_new();
for(int i = 0; i < num; ++i) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment