blob: 1d282a9f14f6d946031d05599ad26ca6da193f46 [file] [log] [blame]
William Lallemand6e9556b2020-05-12 17:52:44 +02001/*
2 *
3 * Copyright (C) 2020 HAProxy Technologies, William Lallemand <wlallemand@haproxy.com>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 *
10 */
Willy Tarreaub2551052020-06-09 09:07:15 +020011#include <sys/stat.h>
12#include <sys/types.h>
William Lallemand6e9556b2020-05-12 17:52:44 +020013
Willy Tarreaub2551052020-06-09 09:07:15 +020014#include <dirent.h>
William Lallemand212e9932020-05-18 08:33:09 +020015#include <errno.h>
William Lallemand6e9556b2020-05-12 17:52:44 +020016#include <stdlib.h>
17#include <string.h>
Willy Tarreauaeed4a82020-06-04 22:01:04 +020018#include <syslog.h>
Willy Tarreaub2551052020-06-09 09:07:15 +020019
20#include <import/ebpttree.h>
21#include <import/ebsttree.h>
William Lallemand6e9556b2020-05-12 17:52:44 +020022
Willy Tarreauf1d32c42020-06-04 21:07:02 +020023#include <haproxy/channel.h>
Willy Tarreau83487a82020-06-04 20:19:54 +020024#include <haproxy/cli.h>
Willy Tarreau8d366972020-05-27 16:10:29 +020025#include <haproxy/errors.h>
Willy Tarreau47d7f902020-06-04 14:25:47 +020026#include <haproxy/ssl_ckch.h>
Willy Tarreau52d88722020-06-04 14:29:23 +020027#include <haproxy/ssl_crtlist.h>
Willy Tarreau209108d2020-06-04 20:30:20 +020028#include <haproxy/ssl_sock.h>
Willy Tarreau5e539c92020-06-04 20:45:39 +020029#include <haproxy/stream_interface.h>
Willy Tarreau48fbcae2020-06-03 18:09:46 +020030#include <haproxy/tools.h>
William Lallemand6e9556b2020-05-12 17:52:44 +020031
William Lallemand6e9556b2020-05-12 17:52:44 +020032
William Lallemand6e9556b2020-05-12 17:52:44 +020033/* release ssl bind conf */
34void ssl_sock_free_ssl_conf(struct ssl_bind_conf *conf)
35{
36 if (conf) {
37#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
38 free(conf->npn_str);
39 conf->npn_str = NULL;
40#endif
41#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
42 free(conf->alpn_str);
43 conf->alpn_str = NULL;
44#endif
45 free(conf->ca_file);
46 conf->ca_file = NULL;
47 free(conf->ca_verify_file);
48 conf->ca_verify_file = NULL;
49 free(conf->crl_file);
50 conf->crl_file = NULL;
51 free(conf->ciphers);
52 conf->ciphers = NULL;
53#if (HA_OPENSSL_VERSION_NUMBER >= 0x10101000L)
54 free(conf->ciphersuites);
55 conf->ciphersuites = NULL;
56#endif
57 free(conf->curves);
58 conf->curves = NULL;
59 free(conf->ecdhe);
60 conf->ecdhe = NULL;
61 }
62}
63
64
65/* free sni filters */
66void crtlist_free_filters(char **args)
67{
68 int i;
69
70 if (!args)
71 return;
72
73 for (i = 0; args[i]; i++)
74 free(args[i]);
75
76 free(args);
77}
78
79/* Alloc and duplicate a char ** array */
80char **crtlist_dup_filters(char **args, int fcount)
81{
82 char **dst;
83 int i;
84
85 if (fcount == 0)
86 return NULL;
87
88 dst = calloc(fcount + 1, sizeof(*dst));
89 if (!dst)
90 return NULL;
91
92 for (i = 0; i < fcount; i++) {
93 dst[i] = strdup(args[i]);
94 if (!dst[i])
95 goto error;
96 }
97 return dst;
98
99error:
100 crtlist_free_filters(dst);
101 return NULL;
102}
103
104/*
105 * Detach and free a crtlist_entry.
106 * Free the filters, the ssl_conf and call ckch_inst_free() for each ckch_inst
107 */
108void crtlist_entry_free(struct crtlist_entry *entry)
109{
110 struct ckch_inst *inst, *inst_s;
111
112 if (entry == NULL)
113 return;
114
115 ebpt_delete(&entry->node);
116 LIST_DEL(&entry->by_crtlist);
117 LIST_DEL(&entry->by_ckch_store);
118 crtlist_free_filters(entry->filters);
119 ssl_sock_free_ssl_conf(entry->ssl_conf);
120 free(entry->ssl_conf);
121 list_for_each_entry_safe(inst, inst_s, &entry->ckch_inst, by_crtlist_entry) {
122 ckch_inst_free(inst);
123 }
124 free(entry);
125}
126
127/*
128 * Allocate and initialize a crtlist_entry
129 */
130struct crtlist_entry *crtlist_entry_new()
131{
132 struct crtlist_entry *entry;
133
134 entry = calloc(1, sizeof(*entry));
135 if (entry == NULL)
136 return NULL;
137
138 LIST_INIT(&entry->ckch_inst);
139
140 /* initialize the nodes so we can LIST_DEL in any cases */
141 LIST_INIT(&entry->by_crtlist);
142 LIST_INIT(&entry->by_ckch_store);
143
144 return entry;
145}
146
147/* Free a crtlist, from the crt_entry to the content of the ssl_conf */
148void crtlist_free(struct crtlist *crtlist)
149{
150 struct crtlist_entry *entry, *s_entry;
William Lallemand6a3168a2020-06-23 11:43:35 +0200151 struct bind_conf_list *bind_conf_node;
William Lallemand6e9556b2020-05-12 17:52:44 +0200152
153 if (crtlist == NULL)
154 return;
155
William Lallemand6a3168a2020-06-23 11:43:35 +0200156 bind_conf_node = crtlist->bind_conf;
157 while (bind_conf_node) {
158 struct bind_conf_list *next = bind_conf_node->next;
159 free(bind_conf_node);
160 bind_conf_node = next;
161 }
162
William Lallemand6e9556b2020-05-12 17:52:44 +0200163 list_for_each_entry_safe(entry, s_entry, &crtlist->ord_entries, by_crtlist) {
164 crtlist_entry_free(entry);
165 }
166 ebmb_delete(&crtlist->node);
167 free(crtlist);
168}
169
170/* Alloc and initialize a struct crtlist
171 * <filename> is the key of the ebmb_node
172 * <unique> initialize the list of entries to be unique (1) or not (0)
173 */
174struct crtlist *crtlist_new(const char *filename, int unique)
175{
176 struct crtlist *newlist;
177
178 newlist = calloc(1, sizeof(*newlist) + strlen(filename) + 1);
179 if (newlist == NULL)
180 return NULL;
181
182 memcpy(newlist->node.key, filename, strlen(filename) + 1);
183 if (unique)
184 newlist->entries = EB_ROOT_UNIQUE;
185 else
186 newlist->entries = EB_ROOT;
187
188 LIST_INIT(&newlist->ord_entries);
189
190 return newlist;
191}
192
193/*
194 * Read a single crt-list line. /!\ alter the <line> string.
195 * Fill <crt_path> and <crtlist_entry>
196 * <crtlist_entry> must be alloc and free by the caller
197 * <crtlist_entry->ssl_conf> is alloc by the function
198 * <crtlist_entry->filters> is alloc by the function
199 * <crt_path> is a ptr in <line>
200 * Return an error code
201 */
202int crtlist_parse_line(char *line, char **crt_path, struct crtlist_entry *entry, const char *file, int linenum, char **err)
203{
204 int cfgerr = 0;
205 int arg, newarg, cur_arg, i, ssl_b = 0, ssl_e = 0;
206 char *end;
207 char *args[MAX_CRT_ARGS + 1];
208 struct ssl_bind_conf *ssl_conf = NULL;
209
210 if (!line || !crt_path || !entry)
211 return ERR_ALERT | ERR_FATAL;
212
213 end = line + strlen(line);
214 if (end-line >= CRT_LINESIZE-1 && *(end-1) != '\n') {
215 /* Check if we reached the limit and the last char is not \n.
216 * Watch out for the last line without the terminating '\n'!
217 */
218 memprintf(err, "line %d too long in file '%s', limit is %d characters",
219 linenum, file, CRT_LINESIZE-1);
220 cfgerr |= ERR_ALERT | ERR_FATAL;
221 goto error;
222 }
223 arg = 0;
224 newarg = 1;
225 while (*line) {
226 if (isspace((unsigned char)*line)) {
227 newarg = 1;
228 *line = 0;
229 } else if (*line == '[') {
230 if (ssl_b) {
231 memprintf(err, "too many '[' on line %d in file '%s'.", linenum, file);
232 cfgerr |= ERR_ALERT | ERR_FATAL;
233 goto error;
234 }
235 if (!arg) {
236 memprintf(err, "file must start with a cert on line %d in file '%s'", linenum, file);
237 cfgerr |= ERR_ALERT | ERR_FATAL;
238 goto error;
239 }
240 ssl_b = arg;
241 newarg = 1;
242 *line = 0;
243 } else if (*line == ']') {
244 if (ssl_e) {
245 memprintf(err, "too many ']' on line %d in file '%s'.", linenum, file);
246 cfgerr |= ERR_ALERT | ERR_FATAL;
247 goto error;
248 }
249 if (!ssl_b) {
250 memprintf(err, "missing '[' in line %d in file '%s'.", linenum, file);
251 cfgerr |= ERR_ALERT | ERR_FATAL;
252 goto error;
253 }
254 ssl_e = arg;
255 newarg = 1;
256 *line = 0;
257 } else if (newarg) {
258 if (arg == MAX_CRT_ARGS) {
259 memprintf(err, "too many args on line %d in file '%s'.", linenum, file);
260 cfgerr |= ERR_ALERT | ERR_FATAL;
261 goto error;
262 }
263 newarg = 0;
264 args[arg++] = line;
265 }
266 line++;
267 }
268 args[arg++] = line;
269
270 /* empty line */
271 if (!*args[0]) {
272 cfgerr |= ERR_NONE;
273 goto error;
274 }
275
276 *crt_path = args[0];
277
278 if (ssl_b) {
279 ssl_conf = calloc(1, sizeof *ssl_conf);
280 if (!ssl_conf) {
281 memprintf(err, "not enough memory!");
282 cfgerr |= ERR_ALERT | ERR_FATAL;
283 goto error;
284 }
285 }
286 cur_arg = ssl_b ? ssl_b : 1;
287 while (cur_arg < ssl_e) {
288 newarg = 0;
289 for (i = 0; ssl_bind_kws[i].kw != NULL; i++) {
290 if (strcmp(ssl_bind_kws[i].kw, args[cur_arg]) == 0) {
291 newarg = 1;
292 cfgerr |= ssl_bind_kws[i].parse(args, cur_arg, NULL, ssl_conf, err);
293 if (cur_arg + 1 + ssl_bind_kws[i].skip > ssl_e) {
294 memprintf(err, "ssl args out of '[]' for %s on line %d in file '%s'",
295 args[cur_arg], linenum, file);
296 cfgerr |= ERR_ALERT | ERR_FATAL;
297 goto error;
298 }
299 cur_arg += 1 + ssl_bind_kws[i].skip;
300 break;
301 }
302 }
303 if (!cfgerr && !newarg) {
304 memprintf(err, "unknown ssl keyword %s on line %d in file '%s'.",
305 args[cur_arg], linenum, file);
306 cfgerr |= ERR_ALERT | ERR_FATAL;
307 goto error;
308 }
309 }
310 entry->linenum = linenum;
311 entry->ssl_conf = ssl_conf;
312 entry->filters = crtlist_dup_filters(&args[cur_arg], arg - cur_arg - 1);
313 entry->fcount = arg - cur_arg - 1;
314
315 return cfgerr;
316
317error:
318 crtlist_free_filters(entry->filters);
319 entry->filters = NULL;
320 ssl_sock_free_ssl_conf(entry->ssl_conf);
321 free(entry->ssl_conf);
322 entry->ssl_conf = NULL;
323 return cfgerr;
324}
325
326
327
328/* This function parse a crt-list file and store it in a struct crtlist, each line is a crtlist_entry structure
329 * Fill the <crtlist> argument with a pointer to a new crtlist struct
330 *
331 * This function tries to open and store certificate files.
332 */
333int crtlist_parse_file(char *file, struct bind_conf *bind_conf, struct proxy *curproxy, struct crtlist **crtlist, char **err)
334{
335 struct crtlist *newlist;
336 struct crtlist_entry *entry = NULL;
337 char thisline[CRT_LINESIZE];
338 char path[MAXPATHLEN+1];
339 FILE *f;
340 struct stat buf;
341 int linenum = 0;
342 int cfgerr = 0;
343
344 if ((f = fopen(file, "r")) == NULL) {
345 memprintf(err, "cannot open file '%s' : %s", file, strerror(errno));
346 return ERR_ALERT | ERR_FATAL;
347 }
348
349 newlist = crtlist_new(file, 0);
350 if (newlist == NULL) {
351 memprintf(err, "Not enough memory!");
352 cfgerr |= ERR_ALERT | ERR_FATAL;
353 goto error;
354 }
355
356 while (fgets(thisline, sizeof(thisline), f) != NULL) {
357 char *end;
358 char *line = thisline;
359 char *crt_path;
360 struct ckch_store *ckchs;
361
362 linenum++;
363 end = line + strlen(line);
364 if (end-line == sizeof(thisline)-1 && *(end-1) != '\n') {
365 /* Check if we reached the limit and the last char is not \n.
366 * Watch out for the last line without the terminating '\n'!
367 */
368 memprintf(err, "line %d too long in file '%s', limit is %d characters",
369 linenum, file, (int)sizeof(thisline)-1);
370 cfgerr |= ERR_ALERT | ERR_FATAL;
371 break;
372 }
373
374 if (*line == '#' || *line == '\n' || *line == '\r')
375 continue;
376
377 entry = crtlist_entry_new();
378 if (entry == NULL) {
379 memprintf(err, "Not enough memory!");
380 cfgerr |= ERR_ALERT | ERR_FATAL;
381 goto error;
382 }
383
384 *(end - 1) = '\0'; /* line parser mustn't receive any \n */
385 cfgerr |= crtlist_parse_line(thisline, &crt_path, entry, file, linenum, err);
386 if (cfgerr)
387 goto error;
388
389 /* empty line */
390 if (!crt_path || !*crt_path) {
391 crtlist_entry_free(entry);
392 entry = NULL;
393 continue;
394 }
395
396 if (*crt_path != '/' && global_ssl.crt_base) {
397 if ((strlen(global_ssl.crt_base) + 1 + strlen(crt_path)) > MAXPATHLEN) {
398 memprintf(err, "'%s' : path too long on line %d in file '%s'",
399 crt_path, linenum, file);
400 cfgerr |= ERR_ALERT | ERR_FATAL;
401 goto error;
402 }
403 snprintf(path, sizeof(path), "%s/%s", global_ssl.crt_base, crt_path);
404 crt_path = path;
405 }
406
407 /* Look for a ckch_store or create one */
408 ckchs = ckchs_lookup(crt_path);
409 if (ckchs == NULL) {
410 if (stat(crt_path, &buf) == 0)
411 ckchs = ckchs_load_cert_file(crt_path, 0, err);
412 else
413 ckchs = ckchs_load_cert_file(crt_path, 1, err);
414 }
415 if (ckchs == NULL)
416 cfgerr |= ERR_ALERT | ERR_FATAL;
417
418 if (cfgerr & ERR_CODE)
419 goto error;
420
421 entry->node.key = ckchs;
422 entry->crtlist = newlist;
423 ebpt_insert(&newlist->entries, &entry->node);
424 LIST_ADDQ(&newlist->ord_entries, &entry->by_crtlist);
425 LIST_ADDQ(&ckchs->crtlist_entry, &entry->by_ckch_store);
426
427 entry = NULL;
428 }
429 if (cfgerr & ERR_CODE)
430 goto error;
431
432 newlist->linecount = linenum;
433
434 fclose(f);
435 *crtlist = newlist;
436
437 return cfgerr;
438error:
439 crtlist_entry_free(entry);
440
441 fclose(f);
442 crtlist_free(newlist);
443 return cfgerr;
444}
445
446/* This function reads a directory and stores it in a struct crtlist, each file is a crtlist_entry structure
447 * Fill the <crtlist> argument with a pointer to a new crtlist struct
448 *
449 * This function tries to open and store certificate files.
450 */
451int crtlist_load_cert_dir(char *path, struct bind_conf *bind_conf, struct crtlist **crtlist, char **err)
452{
453 struct crtlist *dir;
454 struct dirent **de_list;
455 int i, n;
456 struct stat buf;
457 char *end;
458 char fp[MAXPATHLEN+1];
459 int cfgerr = 0;
460 struct ckch_store *ckchs;
461#if HA_OPENSSL_VERSION_NUMBER >= 0x1000200fL
462 int is_bundle;
463 int j;
464#endif
465
466 dir = crtlist_new(path, 1);
467 if (dir == NULL) {
468 memprintf(err, "not enough memory");
469 return ERR_ALERT | ERR_FATAL;
470 }
471
472 n = scandir(path, &de_list, 0, alphasort);
473 if (n < 0) {
474 memprintf(err, "%sunable to scan directory '%s' : %s.\n",
475 err && *err ? *err : "", path, strerror(errno));
476 cfgerr |= ERR_ALERT | ERR_FATAL;
477 }
478 else {
479 for (i = 0; i < n; i++) {
480 struct crtlist_entry *entry;
481 struct dirent *de = de_list[i];
482
483 end = strrchr(de->d_name, '.');
484 if (end && (!strcmp(end, ".issuer") || !strcmp(end, ".ocsp") || !strcmp(end, ".sctl") || !strcmp(end, ".key")))
485 goto ignore_entry;
486
487 snprintf(fp, sizeof(fp), "%s/%s", path, de->d_name);
488 if (stat(fp, &buf) != 0) {
489 memprintf(err, "%sunable to stat SSL certificate from file '%s' : %s.\n",
490 err && *err ? *err : "", fp, strerror(errno));
491 cfgerr |= ERR_ALERT | ERR_FATAL;
492 goto ignore_entry;
493 }
494 if (!S_ISREG(buf.st_mode))
495 goto ignore_entry;
496
497 entry = crtlist_entry_new();
498 if (entry == NULL) {
499 memprintf(err, "not enough memory '%s'", fp);
500 cfgerr |= ERR_ALERT | ERR_FATAL;
501 goto ignore_entry;
502 }
503
504#if HA_OPENSSL_VERSION_NUMBER >= 0x1000200fL
505 is_bundle = 0;
506 /* Check if current entry in directory is part of a multi-cert bundle */
507
508 if ((global_ssl.extra_files & SSL_GF_BUNDLE) && end) {
509 for (j = 0; j < SSL_SOCK_NUM_KEYTYPES; j++) {
510 if (!strcmp(end + 1, SSL_SOCK_KEYTYPE_NAMES[j])) {
511 is_bundle = 1;
512 break;
513 }
514 }
515
516 if (is_bundle) {
517 int dp_len;
518
519 dp_len = end - de->d_name;
520
521 /* increment i and free de until we get to a non-bundle cert
522 * Note here that we look at de_list[i + 1] before freeing de
523 * this is important since ignore_entry will free de. This also
524 * guarantees that de->d_name continues to hold the same prefix.
525 */
526 while (i + 1 < n && !strncmp(de_list[i + 1]->d_name, de->d_name, dp_len)) {
527 free(de);
528 i++;
529 de = de_list[i];
530 }
531
532 snprintf(fp, sizeof(fp), "%s/%.*s", path, dp_len, de->d_name);
533 ckchs = ckchs_lookup(fp);
534 if (ckchs == NULL)
535 ckchs = ckchs_load_cert_file(fp, 1, err);
536 if (ckchs == NULL) {
537 free(de);
538 free(entry);
539 cfgerr |= ERR_ALERT | ERR_FATAL;
540 goto end;
541 }
542 entry->node.key = ckchs;
543 entry->crtlist = dir;
544 LIST_ADDQ(&ckchs->crtlist_entry, &entry->by_ckch_store);
545 LIST_ADDQ(&dir->ord_entries, &entry->by_crtlist);
546 ebpt_insert(&dir->entries, &entry->node);
547
548 /* Successfully processed the bundle */
549 goto ignore_entry;
550 }
551 }
552
553#endif
554 ckchs = ckchs_lookup(fp);
555 if (ckchs == NULL)
556 ckchs = ckchs_load_cert_file(fp, 0, err);
557 if (ckchs == NULL) {
558 free(de);
559 free(entry);
560 cfgerr |= ERR_ALERT | ERR_FATAL;
561 goto end;
562 }
563 entry->node.key = ckchs;
564 entry->crtlist = dir;
565 LIST_ADDQ(&ckchs->crtlist_entry, &entry->by_ckch_store);
566 LIST_ADDQ(&dir->ord_entries, &entry->by_crtlist);
567 ebpt_insert(&dir->entries, &entry->node);
568
569ignore_entry:
570 free(de);
571 }
572end:
573 free(de_list);
574 }
575
576 if (cfgerr & ERR_CODE) {
577 /* free the dir and entries on error */
578 crtlist_free(dir);
579 } else {
580 *crtlist = dir;
581 }
582 return cfgerr;
583
584}
585
William Lallemandc756bbd2020-05-13 17:23:59 +0200586/*
587 * Take an ssl_bind_conf structure and append the configuration line used to
588 * create it in the buffer
589 */
590static void dump_crtlist_sslconf(struct buffer *buf, const struct ssl_bind_conf *conf)
591{
592 int space = 0;
593
594 if (conf == NULL)
595 return;
596
597 chunk_appendf(buf, " [");
598#ifdef OPENSSL_NPN_NEGOTIATED
599 if (conf->npn_str) {
600 int len = conf->npn_len;
601 char *ptr = conf->npn_str;
602 int comma = 0;
603
604 if (space) chunk_appendf(buf, " ");
605 chunk_appendf(buf, "npn ");
606 while (len) {
607 unsigned short size;
608
609 size = *ptr;
610 ptr++;
611 if (comma)
612 chunk_memcat(buf, ",", 1);
613 chunk_memcat(buf, ptr, size);
614 ptr += size;
615 len -= size + 1;
616 comma = 1;
617 }
618 chunk_memcat(buf, "", 1); /* finish with a \0 */
619 space++;
620 }
621#endif
622#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
623 if (conf->alpn_str) {
624 int len = conf->alpn_len;
625 char *ptr = conf->alpn_str;
626 int comma = 0;
627
628 if (space) chunk_appendf(buf, " ");
629 chunk_appendf(buf, "alpn ");
630 while (len) {
631 unsigned short size;
632
633 size = *ptr;
634 ptr++;
635 if (comma)
636 chunk_memcat(buf, ",", 1);
637 chunk_memcat(buf, ptr, size);
638 ptr += size;
639 len -= size + 1;
640 comma = 1;
641 }
642 chunk_memcat(buf, "", 1); /* finish with a \0 */
643 space++;
644 }
645#endif
646 /* verify */
647 {
648 if (conf->verify == SSL_SOCK_VERIFY_NONE) {
649 if (space) chunk_appendf(buf, " ");
650 chunk_appendf(buf, "verify none");
651 space++;
652 } else if (conf->verify == SSL_SOCK_VERIFY_OPTIONAL) {
653 if (space) chunk_appendf(buf, " ");
654 chunk_appendf(buf, "verify optional");
655 space++;
656 } else if (conf->verify == SSL_SOCK_VERIFY_REQUIRED) {
657 if (space) chunk_appendf(buf, " ");
658 chunk_appendf(buf, "verify required");
659 space++;
660 }
661 }
662
663 if (conf->no_ca_names) {
664 if (space) chunk_appendf(buf, " ");
665 chunk_appendf(buf, "no-ca-names");
666 space++;
667 }
668
669 if (conf->early_data) {
670 if (space) chunk_appendf(buf, " ");
671 chunk_appendf(buf, "allow-0rtt");
672 space++;
673 }
674 if (conf->ca_file) {
675 if (space) chunk_appendf(buf, " ");
676 chunk_appendf(buf, "ca-file %s", conf->ca_file);
677 space++;
678 }
679 if (conf->crl_file) {
680 if (space) chunk_appendf(buf, " ");
681 chunk_appendf(buf, "crl-file %s", conf->crl_file);
682 space++;
683 }
684 if (conf->ciphers) {
685 if (space) chunk_appendf(buf, " ");
686 chunk_appendf(buf, "ciphers %s", conf->ciphers);
687 space++;
688 }
689#if (HA_OPENSSL_VERSION_NUMBER >= 0x10101000L && !defined OPENSSL_IS_BORINGSSL && !defined LIBRESSL_VERSION_NUMBER)
690 if (conf->ciphersuites) {
691 if (space) chunk_appendf(buf, " ");
692 chunk_appendf(buf, "ciphersuites %s", conf->ciphersuites);
693 space++;
694 }
695#endif
696 if (conf->curves) {
697 if (space) chunk_appendf(buf, " ");
698 chunk_appendf(buf, "curves %s", conf->curves);
699 space++;
700 }
701 if (conf->ecdhe) {
702 if (space) chunk_appendf(buf, " ");
703 chunk_appendf(buf, "ecdhe %s", conf->ecdhe);
704 space++;
705 }
706
707 /* the crt-lists only support ssl-min-ver and ssl-max-ver */
William Lallemand8177ad92020-05-20 16:49:02 +0200708 if (conf->ssl_methods_cfg.min) {
William Lallemandc756bbd2020-05-13 17:23:59 +0200709 if (space) chunk_appendf(buf, " ");
William Lallemand8177ad92020-05-20 16:49:02 +0200710 chunk_appendf(buf, "ssl-min-ver %s", methodVersions[conf->ssl_methods_cfg.min].name);
William Lallemandc756bbd2020-05-13 17:23:59 +0200711 space++;
712 }
713
William Lallemand8177ad92020-05-20 16:49:02 +0200714 if (conf->ssl_methods_cfg.max) {
William Lallemandc756bbd2020-05-13 17:23:59 +0200715 if (space) chunk_appendf(buf, " ");
William Lallemand8177ad92020-05-20 16:49:02 +0200716 chunk_appendf(buf, "ssl-max-ver %s", methodVersions[conf->ssl_methods_cfg.max].name);
William Lallemandc756bbd2020-05-13 17:23:59 +0200717 space++;
718 }
719
720 chunk_appendf(buf, "]");
721
722 return;
723}
724
725/* dump a list of filters */
726static void dump_crtlist_filters(struct buffer *buf, struct crtlist_entry *entry)
727{
728 int i;
729
730 if (!entry->fcount)
731 return;
732
733 for (i = 0; i < entry->fcount; i++) {
734 chunk_appendf(buf, " %s", entry->filters[i]);
735 }
736 return;
737}
738
739/************************** CLI functions ****************************/
740
741
742/* CLI IO handler for '(show|dump) ssl crt-list' */
743static int cli_io_handler_dump_crtlist(struct appctx *appctx)
744{
745 struct buffer *trash = alloc_trash_chunk();
746 struct stream_interface *si = appctx->owner;
747 struct ebmb_node *lnode;
748
749 if (trash == NULL)
750 return 1;
751
752 /* dump the list of crt-lists */
753 lnode = appctx->ctx.cli.p1;
754 if (lnode == NULL)
755 lnode = ebmb_first(&crtlists_tree);
756 while (lnode) {
757 chunk_appendf(trash, "%s\n", lnode->key);
758 if (ci_putchk(si_ic(si), trash) == -1) {
759 si_rx_room_blk(si);
760 goto yield;
761 }
762 lnode = ebmb_next(lnode);
763 }
764 free_trash_chunk(trash);
765 return 1;
766yield:
767 appctx->ctx.cli.p1 = lnode;
768 free_trash_chunk(trash);
769 return 0;
770}
771
772/* CLI IO handler for '(show|dump) ssl crt-list <filename>' */
773static int cli_io_handler_dump_crtlist_entries(struct appctx *appctx)
774{
775 struct buffer *trash = alloc_trash_chunk();
776 struct crtlist *crtlist;
777 struct stream_interface *si = appctx->owner;
778 struct crtlist_entry *entry;
779
780 if (trash == NULL)
781 return 1;
782
783 crtlist = ebmb_entry(appctx->ctx.cli.p0, struct crtlist, node);
784
785 entry = appctx->ctx.cli.p1;
786 if (entry == NULL) {
787 entry = LIST_ELEM((crtlist->ord_entries).n, typeof(entry), by_crtlist);
788 chunk_appendf(trash, "# %s\n", crtlist->node.key);
789 if (ci_putchk(si_ic(si), trash) == -1) {
790 si_rx_room_blk(si);
791 goto yield;
792 }
793 }
794
795 list_for_each_entry_from(entry, &crtlist->ord_entries, by_crtlist) {
796 struct ckch_store *store;
797 const char *filename;
798
799 store = entry->node.key;
800 filename = store->path;
801 chunk_appendf(trash, "%s", filename);
802 if (appctx->ctx.cli.i0 == 's') /* show */
803 chunk_appendf(trash, ":%d", entry->linenum);
804 dump_crtlist_sslconf(trash, entry->ssl_conf);
805 dump_crtlist_filters(trash, entry);
806 chunk_appendf(trash, "\n");
807
808 if (ci_putchk(si_ic(si), trash) == -1) {
809 si_rx_room_blk(si);
810 goto yield;
811 }
812 }
813 free_trash_chunk(trash);
814 return 1;
815yield:
816 appctx->ctx.cli.p1 = entry;
817 free_trash_chunk(trash);
818 return 0;
819}
820
821/* CLI argument parser for '(show|dump) ssl crt-list' */
822static int cli_parse_dump_crtlist(char **args, char *payload, struct appctx *appctx, void *private)
823{
824 struct ebmb_node *lnode;
825 char *filename = NULL;
826 int mode;
827
828 if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
829 return 1;
830
831 appctx->ctx.cli.p0 = NULL;
832 appctx->ctx.cli.p1 = NULL;
833
834 if (*args[3] && !strcmp(args[3], "-n")) {
835 mode = 's';
836 filename = args[4];
837 } else {
838 mode = 'd';
839 filename = args[3];
840 }
841
842 if (mode == 's' && !*args[4])
843 return cli_err(appctx, "'show ssl crt-list -n' expects a filename or a directory\n");
844
845 if (filename && *filename) {
846 lnode = ebst_lookup(&crtlists_tree, filename);
847 if (lnode == NULL)
848 return cli_err(appctx, "didn't find the specified filename\n");
849
850 appctx->ctx.cli.p0 = lnode;
851 appctx->io_handler = cli_io_handler_dump_crtlist_entries;
852 }
853 appctx->ctx.cli.i0 = mode;
854
855 return 0;
856}
857
858/* release function of the "add ssl crt-list' command, free things and unlock
859 the spinlock */
860static void cli_release_add_crtlist(struct appctx *appctx)
861{
862 struct crtlist_entry *entry = appctx->ctx.cli.p1;
863
864 if (appctx->st2 != SETCERT_ST_FIN) {
865 struct ckch_inst *inst, *inst_s;
866 /* upon error free the ckch_inst and everything inside */
867 ebpt_delete(&entry->node);
868 LIST_DEL(&entry->by_crtlist);
869 LIST_DEL(&entry->by_ckch_store);
870
871 list_for_each_entry_safe(inst, inst_s, &entry->ckch_inst, by_ckchs) {
872 ckch_inst_free(inst);
873 }
874 crtlist_free_filters(entry->filters);
875 ssl_sock_free_ssl_conf(entry->ssl_conf);
876 free(entry->ssl_conf);
877 free(entry);
878 }
879
880 HA_SPIN_UNLOCK(CKCH_LOCK, &ckch_lock);
881}
882
883
884/* IO Handler for the "add ssl crt-list" command It adds a new entry in the
885 * crt-list and generates the ckch_insts for each bind_conf that uses this crt-list
886 *
887 * The logic is the same as the "commit ssl cert" command but without the
888 * freeing of the old structures, because there are none.
889 */
890static int cli_io_handler_add_crtlist(struct appctx *appctx)
891{
892 struct bind_conf_list *bind_conf_node;
893 struct stream_interface *si = appctx->owner;
894 struct crtlist *crtlist = appctx->ctx.cli.p0;
895 struct crtlist_entry *entry = appctx->ctx.cli.p1;
896 struct ckch_store *store = entry->node.key;
897 struct buffer *trash = alloc_trash_chunk();
898 struct ckch_inst *new_inst;
899 char *err = NULL;
900 int i = 0;
901 int errcode = 0;
902
903 if (trash == NULL)
904 goto error;
905
906 /* for each bind_conf which use the crt-list, a new ckch_inst must be
907 * created.
908 */
909 if (unlikely(si_ic(si)->flags & (CF_WRITE_ERROR|CF_SHUTW)))
910 goto error;
911
912 while (1) {
913 switch (appctx->st2) {
914 case SETCERT_ST_INIT:
915 /* This state just print the update message */
916 chunk_printf(trash, "Inserting certificate '%s' in crt-list '%s'", store->path, crtlist->node.key);
917 if (ci_putchk(si_ic(si), trash) == -1) {
918 si_rx_room_blk(si);
919 goto yield;
920 }
921 appctx->st2 = SETCERT_ST_GEN;
922 /* fallthrough */
923 case SETCERT_ST_GEN:
924 bind_conf_node = appctx->ctx.cli.p2; /* get the previous ptr from the yield */
925 if (bind_conf_node == NULL)
926 bind_conf_node = crtlist->bind_conf;
927 for (; bind_conf_node; bind_conf_node = bind_conf_node->next) {
928 struct bind_conf *bind_conf = bind_conf_node->bind_conf;
929 struct sni_ctx *sni;
930
931 /* yield every 10 generations */
932 if (i > 10) {
933 appctx->ctx.cli.p2 = bind_conf_node;
934 goto yield;
935 }
936
937 /* we don't support multi-cert bundles, only simple ones */
938 errcode |= ckch_inst_new_load_store(store->path, store, bind_conf, entry->ssl_conf, entry->filters, entry->fcount, &new_inst, &err);
939 if (errcode & ERR_CODE)
940 goto error;
941
942 /* we need to initialize the SSL_CTX generated */
943 /* this iterate on the newly generated SNIs in the new instance to prepare their SSL_CTX */
944 list_for_each_entry(sni, &new_inst->sni_ctx, by_ckch_inst) {
945 if (!sni->order) { /* we initialized only the first SSL_CTX because it's the same in the other sni_ctx's */
946 errcode |= ssl_sock_prepare_ctx(bind_conf, new_inst->ssl_conf, sni->ctx, &err);
947 if (errcode & ERR_CODE)
948 goto error;
949 }
950 }
951 /* display one dot for each new instance */
952 chunk_appendf(trash, ".");
953 i++;
954 LIST_ADDQ(&store->ckch_inst, &new_inst->by_ckchs);
955 }
956 appctx->st2 = SETCERT_ST_INSERT;
957 /* fallthrough */
958 case SETCERT_ST_INSERT:
959 /* insert SNIs in bind_conf */
960 list_for_each_entry(new_inst, &store->ckch_inst, by_ckchs) {
961 HA_RWLOCK_WRLOCK(SNI_LOCK, &new_inst->bind_conf->sni_lock);
962 ssl_sock_load_cert_sni(new_inst, new_inst->bind_conf);
963 HA_RWLOCK_WRUNLOCK(SNI_LOCK, &new_inst->bind_conf->sni_lock);
964 }
965 entry->linenum = ++crtlist->linecount;
966 appctx->st2 = SETCERT_ST_FIN;
967 goto end;
968 }
969 }
970
971end:
972 chunk_appendf(trash, "\n");
973 if (errcode & ERR_WARN)
974 chunk_appendf(trash, "%s", err);
975 chunk_appendf(trash, "Success!\n");
976 if (ci_putchk(si_ic(si), trash) == -1)
977 si_rx_room_blk(si);
978 free_trash_chunk(trash);
979 /* success: call the release function and don't come back */
980 return 1;
981yield:
982 /* store the state */
983 if (ci_putchk(si_ic(si), trash) == -1)
984 si_rx_room_blk(si);
985 free_trash_chunk(trash);
986 si_rx_endp_more(si); /* let's come back later */
987 return 0; /* should come back */
988
989error:
990 /* spin unlock and free are done in the release function */
991 if (trash) {
992 chunk_appendf(trash, "\n%sFailed!\n", err);
993 if (ci_putchk(si_ic(si), trash) == -1)
994 si_rx_room_blk(si);
995 free_trash_chunk(trash);
996 }
997 /* error: call the release function and don't come back */
998 return 1;
999}
1000
1001
1002/*
1003 * Parse a "add ssl crt-list <crt-list> <certfile>" line.
1004 * Filters and option must be passed through payload:
1005 */
1006static int cli_parse_add_crtlist(char **args, char *payload, struct appctx *appctx, void *private)
1007{
1008 int cfgerr = 0;
1009 struct ckch_store *store;
1010 char *err = NULL;
1011 char path[MAXPATHLEN+1];
1012 char *crtlist_path;
1013 char *cert_path = NULL;
1014 struct ebmb_node *eb;
1015 struct ebpt_node *inserted;
1016 struct crtlist *crtlist;
1017 struct crtlist_entry *entry = NULL;
1018
1019 if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
1020 return 1;
1021
1022 if (!*args[3] || (!payload && !*args[4]))
1023 return cli_err(appctx, "'add ssl crtlist' expects a filename and a certificate name\n");
1024
1025 crtlist_path = args[3];
1026
1027 if (HA_SPIN_TRYLOCK(CKCH_LOCK, &ckch_lock))
1028 return cli_err(appctx, "Operations on certificates are currently locked!\n");
1029
1030 eb = ebst_lookup(&crtlists_tree, crtlist_path);
1031 if (!eb) {
1032 memprintf(&err, "crt-list '%s' does not exist!", crtlist_path);
1033 goto error;
1034 }
1035 crtlist = ebmb_entry(eb, struct crtlist, node);
1036
1037 entry = crtlist_entry_new();
1038 if (entry == NULL) {
1039 memprintf(&err, "Not enough memory!");
1040 goto error;
1041 }
1042
1043 if (payload) {
1044 char *lf;
1045
1046 lf = strrchr(payload, '\n');
1047 if (lf) {
1048 memprintf(&err, "only one line of payload is supported!");
1049 goto error;
1050 }
1051 /* cert_path is filled here */
1052 cfgerr |= crtlist_parse_line(payload, &cert_path, entry, "CLI", 1, &err);
1053 if (cfgerr & ERR_CODE)
1054 goto error;
1055 } else {
1056 cert_path = args[4];
1057 }
1058
1059 if (!cert_path) {
1060 memprintf(&err, "'add ssl crtlist' should contain the certificate name in the payload");
1061 cfgerr |= ERR_ALERT | ERR_FATAL;
1062 goto error;
1063 }
1064
1065 if (eb_gettag(crtlist->entries.b[EB_RGHT])) {
1066 char *slash;
1067
1068 slash = strrchr(cert_path, '/');
1069 if (!slash) {
1070 memprintf(&err, "'%s' is a directory, certificate path '%s' must contain the directory path", (char *)crtlist->node.key, cert_path);
1071 goto error;
1072 }
1073 /* temporary replace / by 0 to do an strcmp */
1074 *slash = '\0';
1075 if (strcmp(cert_path, (char*)crtlist->node.key) != 0) {
1076 *slash = '/';
1077 memprintf(&err, "'%s' is a directory, certificate path '%s' must contain the directory path", (char *)crtlist->node.key, cert_path);
1078 goto error;
1079 }
1080 *slash = '/';
1081 }
1082
1083 if (*cert_path != '/' && global_ssl.crt_base) {
1084 if ((strlen(global_ssl.crt_base) + 1 + strlen(cert_path)) > MAXPATHLEN) {
1085 memprintf(&err, "'%s' : path too long", cert_path);
1086 cfgerr |= ERR_ALERT | ERR_FATAL;
1087 goto error;
1088 }
1089 snprintf(path, sizeof(path), "%s/%s", global_ssl.crt_base, cert_path);
1090 cert_path = path;
1091 }
1092
1093 store = ckchs_lookup(cert_path);
1094 if (store == NULL) {
1095 memprintf(&err, "certificate '%s' does not exist!", cert_path);
1096 goto error;
1097 }
1098 if (store->multi) {
1099 memprintf(&err, "certificate '%s' is a bundle. You can disable the bundle merging with the directive 'ssl-load-extra-files' in the global section.", cert_path);
1100 goto error;
1101 }
1102 if (store->ckch == NULL || store->ckch->cert == NULL) {
1103 memprintf(&err, "certificate '%s' is empty!", cert_path);
1104 goto error;
1105 }
1106
1107 /* check if it's possible to insert this new crtlist_entry */
1108 entry->node.key = store;
1109 inserted = ebpt_insert(&crtlist->entries, &entry->node);
1110 if (inserted != &entry->node) {
1111 memprintf(&err, "file already exists in this directory!");
1112 goto error;
1113 }
1114
1115 /* this is supposed to be a directory (EB_ROOT_UNIQUE), so no ssl_conf are allowed */
1116 if ((entry->ssl_conf || entry->filters) && eb_gettag(crtlist->entries.b[EB_RGHT])) {
1117 memprintf(&err, "this is a directory, SSL configuration and filters are not allowed");
1118 goto error;
1119 }
1120
1121 LIST_ADDQ(&crtlist->ord_entries, &entry->by_crtlist);
1122 entry->crtlist = crtlist;
1123 LIST_ADDQ(&store->crtlist_entry, &entry->by_ckch_store);
1124
1125 appctx->st2 = SETCERT_ST_INIT;
1126 appctx->ctx.cli.p0 = crtlist;
1127 appctx->ctx.cli.p1 = entry;
1128
1129 /* unlock is done in the release handler */
1130 return 0;
1131
1132error:
1133 crtlist_entry_free(entry);
1134 HA_SPIN_UNLOCK(CKCH_LOCK, &ckch_lock);
1135 err = memprintf(&err, "Can't edit the crt-list: %s\n", err ? err : "");
1136 return cli_dynerr(appctx, err);
1137}
1138
1139/* Parse a "del ssl crt-list <crt-list> <certfile>" line. */
1140static int cli_parse_del_crtlist(char **args, char *payload, struct appctx *appctx, void *private)
1141{
1142 struct ckch_store *store;
1143 char *err = NULL;
1144 char *crtlist_path, *cert_path;
1145 struct ebmb_node *ebmb;
1146 struct ebpt_node *ebpt;
1147 struct crtlist *crtlist;
1148 struct crtlist_entry *entry = NULL;
1149 struct ckch_inst *inst, *inst_s;
1150 int linenum = 0;
1151 char *colons;
1152
1153 if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
1154 return 1;
1155
1156 if (!*args[3] || !*args[4])
1157 return cli_err(appctx, "'del ssl crtlist' expects a filename and a certificate name\n");
1158
1159 if (HA_SPIN_TRYLOCK(CKCH_LOCK, &ckch_lock))
1160 return cli_err(appctx, "Can't delete!\nOperations on certificates are currently locked!\n");
1161
1162 crtlist_path = args[3];
1163 cert_path = args[4];
1164
1165 colons = strchr(cert_path, ':');
1166 if (colons) {
1167 char *endptr;
1168
1169 linenum = strtol(colons + 1, &endptr, 10);
1170 if (colons + 1 == endptr || *endptr != '\0') {
1171 memprintf(&err, "wrong line number after colons in '%s'!", cert_path);
1172 goto error;
1173 }
1174 *colons = '\0';
1175 }
1176 /* look for crtlist */
1177 ebmb = ebst_lookup(&crtlists_tree, crtlist_path);
1178 if (!ebmb) {
1179 memprintf(&err, "crt-list '%s' does not exist!", crtlist_path);
1180 goto error;
1181 }
1182 crtlist = ebmb_entry(ebmb, struct crtlist, node);
1183
1184 /* look for store */
1185 store = ckchs_lookup(cert_path);
1186 if (store == NULL) {
1187 memprintf(&err, "certificate '%s' does not exist!", cert_path);
1188 goto error;
1189 }
1190 if (store->multi) {
1191 memprintf(&err, "certificate '%s' is a bundle. You can disable the bundle merging with the directive 'ssl-load-extra-files' in the global section.", cert_path);
1192 goto error;
1193 }
1194 if (store->ckch == NULL || store->ckch->cert == NULL) {
1195 memprintf(&err, "certificate '%s' is empty!", cert_path);
1196 goto error;
1197 }
1198
1199 ebpt = ebpt_lookup(&crtlist->entries, store);
1200 if (!ebpt) {
1201 memprintf(&err, "certificate '%s' can't be found in crt-list '%s'!", cert_path, crtlist_path);
1202 goto error;
1203 }
1204
1205 /* list the line number of entries for errors in err, and select the right ebpt */
1206 for (; ebpt; ebpt = ebpt_next_dup(ebpt)) {
1207 struct crtlist_entry *tmp;
1208
1209 tmp = ebpt_entry(ebpt, struct crtlist_entry, node);
1210 memprintf(&err, "%s%s%d", err ? err : "", err ? ", " : "", tmp->linenum);
1211
1212 /* select the entry we wanted */
1213 if (linenum == 0 || tmp->linenum == linenum) {
1214 if (!entry)
1215 entry = tmp;
1216 }
1217 }
1218
1219 /* we didn't found the specified entry */
1220 if (!entry) {
1221 memprintf(&err, "found a certificate '%s' but the line number is incorrect, please specify a correct line number preceded by colons (%s)!", cert_path, err ? err : NULL);
1222 goto error;
1223 }
1224
1225 /* we didn't specified a line number but there were several entries */
1226 if (linenum == 0 && ebpt_next_dup(&entry->node)) {
1227 memprintf(&err, "found the certificate '%s' in several entries, please specify a line number preceded by colons (%s)!", cert_path, err ? err : NULL);
1228 goto error;
1229 }
1230
1231 /* upon error free the ckch_inst and everything inside */
1232
1233 ebpt_delete(&entry->node);
1234 LIST_DEL(&entry->by_crtlist);
1235 LIST_DEL(&entry->by_ckch_store);
1236
1237 list_for_each_entry_safe(inst, inst_s, &entry->ckch_inst, by_crtlist_entry) {
1238 struct sni_ctx *sni, *sni_s;
1239
1240 HA_RWLOCK_WRLOCK(SNI_LOCK, &inst->bind_conf->sni_lock);
1241 list_for_each_entry_safe(sni, sni_s, &inst->sni_ctx, by_ckch_inst) {
1242 ebmb_delete(&sni->name);
1243 LIST_DEL(&sni->by_ckch_inst);
1244 SSL_CTX_free(sni->ctx);
1245 free(sni);
1246 }
1247 HA_RWLOCK_WRUNLOCK(SNI_LOCK, &inst->bind_conf->sni_lock);
1248 LIST_DEL(&inst->by_ckchs);
1249 free(inst);
1250 }
1251
1252 crtlist_free_filters(entry->filters);
1253 ssl_sock_free_ssl_conf(entry->ssl_conf);
1254 free(entry->ssl_conf);
1255 free(entry);
1256
1257 HA_SPIN_UNLOCK(CKCH_LOCK, &ckch_lock);
1258 err = memprintf(&err, "Entry '%s' deleted in crtlist '%s'!\n", cert_path, crtlist_path);
1259 return cli_dynmsg(appctx, LOG_NOTICE, err);
1260
1261error:
1262 HA_SPIN_UNLOCK(CKCH_LOCK, &ckch_lock);
1263 err = memprintf(&err, "Can't delete the entry: %s\n", err ? err : "");
1264 return cli_dynerr(appctx, err);
1265}
1266
1267
William Lallemandee8530c2020-06-23 18:19:42 +02001268/* unlink and free all crt-list and crt-list entries */
1269void crtlist_deinit()
1270{
1271 struct eb_node *node, *next;
1272 struct crtlist *crtlist;
1273
1274 node = eb_first(&crtlists_tree);
1275 while (node) {
1276 next = eb_next(node);
1277 crtlist = ebmb_entry(node, struct crtlist, node);
1278 crtlist_free(crtlist);
1279 node = next;
1280 }
1281}
1282
William Lallemandc756bbd2020-05-13 17:23:59 +02001283
1284/* register cli keywords */
1285static struct cli_kw_list cli_kws = {{ },{
1286 { { "add", "ssl", "crt-list", NULL }, "add ssl crt-list <filename> <certfile> [options] : add a line <certfile> to a crt-list <filename>", cli_parse_add_crtlist, cli_io_handler_add_crtlist, cli_release_add_crtlist },
1287 { { "del", "ssl", "crt-list", NULL }, "del ssl crt-list <filename> <certfile[:line]> : delete a line <certfile> in a crt-list <filename>", cli_parse_del_crtlist, NULL, NULL },
1288 { { "show", "ssl", "crt-list", NULL }, "show ssl crt-list [-n] [<filename>] : show the list of crt-lists or the content of a crt-list <filename>", cli_parse_dump_crtlist, cli_io_handler_dump_crtlist, NULL },
1289 { { NULL }, NULL, NULL, NULL } }
1290};
1291
1292INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
1293