Postfix3.3.1
全て データ構造 ファイル 関数 変数 型定義 マクロ定義
tls_misc.c
[詳解]
1 /*++
2 /* NAME
3 /* tls_misc 3
4 /* SUMMARY
5 /* miscellaneous TLS support routines
6 /* SYNOPSIS
7 /* #define TLS_INTERNAL
8 /* #include <tls.h>
9 /*
10 /* char *var_tls_high_clist;
11 /* char *var_tls_medium_clist;
12 /* char *var_tls_low_clist;
13 /* char *var_tls_export_clist;
14 /* char *var_tls_null_clist;
15 /* char *var_tls_eecdh_auto;
16 /* char *var_tls_eecdh_strong;
17 /* char *var_tls_eecdh_ultra;
18 /* char *var_tls_dane_agility;
19 /* char *var_tls_dane_digests;
20 /* int var_tls_daemon_rand_bytes;
21 /* bool var_tls_append_def_CA;
22 /* bool var_tls_dane_taa_dgst;
23 /* bool var_tls_preempt_clist;
24 /* bool var_tls_bc_pkey_fprint;
25 /* bool var_tls_multi_wildcard;
26 /* char *var_tls_mgr_service;
27 /* char *var_tls_tkt_cipher;
28 /* char *var_openssl_path;
29 /*
30 /* TLS_APPL_STATE *tls_alloc_app_context(ssl_ctx, log_mask)
31 /* SSL_CTX *ssl_ctx;
32 /* int log_mask;
33 /*
34 /* void tls_free_app_context(app_ctx)
35 /* void *app_ctx;
36 /*
37 /* TLS_SESS_STATE *tls_alloc_sess_context(log_mask, namaddr)
38 /* int log_mask;
39 /* const char *namaddr;
40 /*
41 /* void tls_free_context(TLScontext)
42 /* TLS_SESS_STATE *TLScontext;
43 /*
44 /* void tls_check_version()
45 /*
46 /* long tls_bug_bits()
47 /*
48 /* void tls_param_init()
49 /*
50 /* int tls_protocol_mask(plist)
51 /* const char *plist;
52 /*
53 /* int tls_cipher_grade(name)
54 /* const char *name;
55 /*
56 /* const char *str_tls_cipher_grade(grade)
57 /* int grade;
58 /*
59 /* const char *tls_set_ciphers(app_ctx, context, grade, exclusions)
60 /* TLS_APPL_STATE *app_ctx;
61 /* const char *context;
62 /* int grade;
63 /* const char *exclusions;
64 /*
65 /* void tls_print_errors()
66 /*
67 /* void tls_info_callback(ssl, where, ret)
68 /* const SSL *ssl; /* unused */
69 /* int where;
70 /* int ret;
71 /*
72 /* long tls_bio_dump_cb(bio, cmd, argp, argi, argl, ret)
73 /* BIO *bio;
74 /* int cmd;
75 /* const char *argp;
76 /* int argi;
77 /* long argl; /* unused */
78 /* long ret;
79 /*
80 /* int tls_log_mask(log_param, log_level)
81 /* const char *log_param;
82 /* const char *log_level;
83 /*
84 /* void tls_update_app_logmask(app_ctx, log_mask)
85 /* TLS_APPL_STATE *app_ctx;
86 /* int log_mask;
87 /*
88 /* int tls_validate_digest(dgst)
89 /* const char *dgst;
90 /*
91 /* const char *tls_compile_version(void)
92 /*
93 /* const char *tls_run_version(void)
94 /*
95 /* const char **tls_pkey_algorithms(void)
96 /* DESCRIPTION
97 /* This module implements routines that support the TLS client
98 /* and server internals.
99 /*
100 /* tls_alloc_app_context() creates an application context that
101 /* holds the SSL context for the application and related cached state.
102 /*
103 /* tls_free_app_context() deallocates the application context and its
104 /* contents (the application context is stored outside the TLS library).
105 /*
106 /* tls_alloc_sess_context() creates an initialized TLS session context
107 /* structure with the specified log mask and peer name[addr].
108 /*
109 /* tls_free_context() destroys a TLScontext structure
110 /* together with OpenSSL structures that are attached to it.
111 /*
112 /* tls_check_version() logs a warning when the run-time OpenSSL
113 /* library differs in its major, minor or micro number from
114 /* the compile-time OpenSSL headers.
115 /*
116 /* tls_bug_bits() returns the bug compatibility mask appropriate
117 /* for the run-time library. Some of the bug work-arounds are
118 /* not appropriate for some library versions.
119 /*
120 /* tls_param_init() loads main.cf parameters used internally in
121 /* TLS library. Any errors are fatal.
122 /*
123 /* tls_protocol_mask() returns a bitmask of excluded protocols, given
124 /* a list (plist) of protocols to include or (preceded by a '!') exclude.
125 /* If "plist" contains invalid protocol names, TLS_PROTOCOL_INVALID is
126 /* returned and no warning is logged.
127 /*
128 /* tls_cipher_grade() converts a case-insensitive cipher grade
129 /* name (high, medium, low, export, null) to the corresponding
130 /* TLS_CIPHER_ constant. When the input specifies an unrecognized
131 /* grade, tls_cipher_grade() logs no warning, and returns
132 /* TLS_CIPHER_NONE.
133 /*
134 /* str_tls_cipher_grade() converts a cipher grade to a name.
135 /* When the input specifies an undefined grade, str_tls_cipher_grade()
136 /* logs no warning, returns a null pointer.
137 /*
138 /* tls_set_ciphers() generates a cipher list from the specified
139 /* grade, minus any ciphers specified via a list of exclusions.
140 /* The cipherlist is applied to the supplied SSL context if it
141 /* is different from the most recently applied value. The return
142 /* value is the cipherlist used and is overwritten upon each call.
143 /* When the input is invalid, tls_set_ciphers() logs a warning with
144 /* the specified context, and returns a null pointer result.
145 /*
146 /* tls_print_errors() queries the OpenSSL error stack,
147 /* logs the error messages, and clears the error stack.
148 /*
149 /* tls_info_callback() is a call-back routine for the
150 /* SSL_CTX_set_info_callback() routine. It logs SSL events
151 /* to the Postfix logfile.
152 /*
153 /* tls_bio_dump_cb() is a call-back routine for the
154 /* BIO_set_callback() routine. It logs SSL content to the
155 /* Postfix logfile.
156 /*
157 /* tls_log_mask() converts a TLS log_level value from string
158 /* to mask. The main.cf parameter name is passed along for
159 /* diagnostics.
160 /*
161 /* tls_update_app_logmask() changes the log mask of the
162 /* application TLS context to the new setting.
163 /*
164 /* tls_validate_digest() returns non-zero if the named digest
165 /* is usable and zero otherwise.
166 /*
167 /* tls_compile_version() returns a text string description of
168 /* the compile-time TLS library.
169 /*
170 /* tls_run_version() is just tls_compile_version() but with the runtime
171 /* version instead of the compile-time version.
172 /*
173 /* tls_pkey_algorithms() returns a pointer to null-terminated
174 /* array of string constants with the names of the supported
175 /* public-key algorithms.
176 /* LICENSE
177 /* .ad
178 /* .fi
179 /* This software is free. You can do with it whatever you want.
180 /* The original author kindly requests that you acknowledge
181 /* the use of his software.
182 /* AUTHOR(S)
183 /* Originally written by:
184 /* Lutz Jaenicke
185 /* BTU Cottbus
186 /* Allgemeine Elektrotechnik
187 /* Universitaetsplatz 3-4
188 /* D-03044 Cottbus, Germany
189 /*
190 /* Updated by:
191 /* Wietse Venema
192 /* IBM T.J. Watson Research
193 /* P.O. Box 704
194 /* Yorktown Heights, NY 10598, USA
195 /*
196 /* Victor Duchovni
197 /* Morgan Stanley
198 /*
199 /* Wietse Venema
200 /* Google, Inc.
201 /* 111 8th Avenue
202 /* New York, NY 10011, USA
203 /*--*/
204 
205 /* System library. */
206 
207 #include <sys_defs.h>
208 #include <ctype.h>
209 #include <string.h>
210 
211 #ifdef USE_TLS
212 
213 /* Utility library. */
214 
215 #include <vstream.h>
216 #include <msg.h>
217 #include <mymalloc.h>
218 #include <vstring.h>
219 #include <stringops.h>
220 #include <argv.h>
221 #include <name_mask.h>
222 #include <name_code.h>
223 
224  /*
225  * Global library.
226  */
227 #include <mail_params.h>
228 #include <mail_conf.h>
229 
230  /*
231  * TLS library.
232  */
233 #define TLS_INTERNAL
234 #include <tls.h>
235 
236  /* Application-specific. */
237 
238  /*
239  * Tunable parameters.
240  */
241 char *var_tls_high_clist;
243 char *var_tls_low_clist;
245 char *var_tls_null_clist;
247 char *var_tls_eecdh_auto;
249 char *var_tls_eecdh_ultra;
253 char *var_tls_bug_tweaks;
254 char *var_tls_ssl_options;
258 char *var_tls_mgr_service;
259 char *var_tls_tkt_cipher;
260 char *var_openssl_path;
261 
262 #ifdef VAR_TLS_PREEMPT_CLIST
264 
265 #endif
266 
267  /*
268  * Index to attach TLScontext pointers to SSL objects, so that they can be
269  * accessed by call-back routines.
270  */
271 int TLScontext_index = -1;
272 
273  /*
274  * Protocol name <=> mask conversion.
275  */
276 static const NAME_CODE protocol_table[] = {
277  SSL_TXT_SSLV2, TLS_PROTOCOL_SSLv2,
278  SSL_TXT_SSLV3, TLS_PROTOCOL_SSLv3,
279  SSL_TXT_TLSV1, TLS_PROTOCOL_TLSv1,
280  SSL_TXT_TLSV1_1, TLS_PROTOCOL_TLSv1_1,
281  SSL_TXT_TLSV1_2, TLS_PROTOCOL_TLSv1_2,
282  SSL_TXT_TLSV1_3, TLS_PROTOCOL_TLSv1_3,
283  0, TLS_PROTOCOL_INVALID,
284 };
285 
286  /*
287  * SSL_OP_MUMBLE bug work-around name <=> mask conversion.
288  */
289 #define NAMEBUG(x) #x, SSL_OP_##x
290 static const LONG_NAME_MASK ssl_bug_tweaks[] = {
291 
292 #ifndef SSL_OP_MICROSOFT_SESS_ID_BUG
293 #define SSL_OP_MICROSOFT_SESS_ID_BUG 0
294 #endif
295  NAMEBUG(MICROSOFT_SESS_ID_BUG),
296 
297 #ifndef SSL_OP_NETSCAPE_CHALLENGE_BUG
298 #define SSL_OP_NETSCAPE_CHALLENGE_BUG 0
299 #endif
300  NAMEBUG(NETSCAPE_CHALLENGE_BUG),
301 
302 #ifndef SSL_OP_LEGACY_SERVER_CONNECT
303 #define SSL_OP_LEGACY_SERVER_CONNECT 0
304 #endif
305  NAMEBUG(LEGACY_SERVER_CONNECT),
306 
307 #ifndef SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG
308 #define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0
309 #endif
310  NAMEBUG(NETSCAPE_REUSE_CIPHER_CHANGE_BUG),
311  "CVE-2010-4180", SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG,
312 
313 #ifndef SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG
314 #define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0
315 #endif
316  NAMEBUG(SSLREF2_REUSE_CERT_TYPE_BUG),
317 
318 #ifndef SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER
319 #define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0
320 #endif
321  NAMEBUG(MICROSOFT_BIG_SSLV3_BUFFER),
322 
323 #ifndef SSL_OP_MSIE_SSLV2_RSA_PADDING
324 #define SSL_OP_MSIE_SSLV2_RSA_PADDING 0
325 #endif
326  NAMEBUG(MSIE_SSLV2_RSA_PADDING),
327  "CVE-2005-2969", SSL_OP_MSIE_SSLV2_RSA_PADDING,
328 
329 #ifndef SSL_OP_SSLEAY_080_CLIENT_DH_BUG
330 #define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0
331 #endif
332  NAMEBUG(SSLEAY_080_CLIENT_DH_BUG),
333 
334 #ifndef SSL_OP_TLS_D5_BUG
335 #define SSL_OP_TLS_D5_BUG 0
336 #endif
337  NAMEBUG(TLS_D5_BUG),
338 
339 #ifndef SSL_OP_TLS_BLOCK_PADDING_BUG
340 #define SSL_OP_TLS_BLOCK_PADDING_BUG 0
341 #endif
342  NAMEBUG(TLS_BLOCK_PADDING_BUG),
343 
344 #ifndef SSL_OP_TLS_ROLLBACK_BUG
345 #define SSL_OP_TLS_ROLLBACK_BUG 0
346 #endif
347  NAMEBUG(TLS_ROLLBACK_BUG),
348 
349 #ifndef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
350 #define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0
351 #endif
352  NAMEBUG(DONT_INSERT_EMPTY_FRAGMENTS),
353 
354 #ifndef SSL_OP_CRYPTOPRO_TLSEXT_BUG
355 #define SSL_OP_CRYPTOPRO_TLSEXT_BUG 0
356 #endif
357  NAMEBUG(CRYPTOPRO_TLSEXT_BUG),
358  0, 0,
359 };
360 
361  /*
362  * SSL_OP_MUMBLE option name <=> mask conversion for options that are not
363  * (or may in the future not be) in SSL_OP_ALL. These enable optional
364  * behavior, rather than bug interoperability work-arounds.
365  */
366 #define NAME_SSL_OP(x) #x, SSL_OP_##x
367 static const LONG_NAME_MASK ssl_op_tweaks[] = {
368 
369 #ifndef SSL_OP_LEGACY_SERVER_CONNECT
370 #define SSL_OP_LEGACY_SERVER_CONNECT 0
371 #endif
372  NAME_SSL_OP(LEGACY_SERVER_CONNECT),
373 
374 #ifndef SSL_OP_NO_TICKET
375 #define SSL_OP_NO_TICKET 0
376 #endif
377  NAME_SSL_OP(NO_TICKET),
378 
379 #ifndef SSL_OP_NO_COMPRESSION
380 #define SSL_OP_NO_COMPRESSION 0
381 #endif
382  NAME_SSL_OP(NO_COMPRESSION),
383  0, 0,
384 };
385 
386  /*
387  * Once these have been a NOOP long enough, they might some day be removed
388  * from OpenSSL. The defines below will avoid bitrot issues if/when that
389  * happens.
390  */
391 #ifndef SSL_OP_SINGLE_DH_USE
392 #define SSL_OP_SINGLE_DH_USE 0
393 #endif
394 #ifndef SSL_OP_SINGLE_ECDH_USE
395 #define SSL_OP_SINGLE_ECDH_USE 0
396 #endif
397 
398  /*
399  * Ciphersuite name <=> code conversion.
400  */
401 const NAME_CODE tls_cipher_grade_table[] = {
402  "high", TLS_CIPHER_HIGH,
403  "medium", TLS_CIPHER_MEDIUM,
404  "low", TLS_CIPHER_LOW,
405  "export", TLS_CIPHER_EXPORT,
406  "null", TLS_CIPHER_NULL,
407  "invalid", TLS_CIPHER_NONE,
408  0, TLS_CIPHER_NONE,
409 };
410 
411  /*
412  * Log keyword <=> mask conversion.
413  */
414 #define TLS_LOG_0 TLS_LOG_NONE
415 #define TLS_LOG_1 TLS_LOG_SUMMARY
416 #define TLS_LOG_2 (TLS_LOG_1 | TLS_LOG_VERBOSE | TLS_LOG_CACHE | TLS_LOG_DEBUG)
417 #define TLS_LOG_3 (TLS_LOG_2 | TLS_LOG_TLSPKTS)
418 #define TLS_LOG_4 (TLS_LOG_3 | TLS_LOG_ALLPKTS)
419 
420 static const NAME_MASK tls_log_table[] = {
421  "0", TLS_LOG_0,
422  "none", TLS_LOG_NONE,
423  "1", TLS_LOG_1,
424  "routine", TLS_LOG_1,
425  "2", TLS_LOG_2,
426  "debug", TLS_LOG_2,
427  "3", TLS_LOG_3,
428  "ssl-expert", TLS_LOG_3,
429  "4", TLS_LOG_4,
430  "ssl-developer", TLS_LOG_4,
431  "5", TLS_LOG_4, /* for good measure */
432  "6", TLS_LOG_4, /* for good measure */
433  "7", TLS_LOG_4, /* for good measure */
434  "8", TLS_LOG_4, /* for good measure */
435  "9", TLS_LOG_4, /* for good measure */
436  "summary", TLS_LOG_SUMMARY,
437  "untrusted", TLS_LOG_UNTRUSTED,
438  "peercert", TLS_LOG_PEERCERT,
439  "certmatch", TLS_LOG_CERTMATCH,
440  "verbose", TLS_LOG_VERBOSE, /* Postfix TLS library verbose */
441  "cache", TLS_LOG_CACHE,
442  "ssl-debug", TLS_LOG_DEBUG, /* SSL library debug/verbose */
443  "ssl-handshake-packet-dump", TLS_LOG_TLSPKTS,
444  "ssl-session-packet-dump", TLS_LOG_TLSPKTS | TLS_LOG_ALLPKTS,
445  0, 0,
446 };
447 
448  /*
449  * Parsed OpenSSL version number.
450  */
451 typedef struct {
452  int major;
453  int minor;
454  int micro;
455  int patch;
456  int status;
457 } TLS_VINFO;
458 
459  /*
460  * OpenSSL adopted the cipher selection patch, so we don't expect any more
461  * broken ciphers other than AES and CAMELLIA.
462  */
463 typedef struct {
464  const char *ssl_name;
465  const int alg_bits;
466  const char *evp_name;
467 } cipher_probe_t;
468 
469 static const cipher_probe_t cipher_probes[] = {
470  "AES", 256, "AES-256-CBC",
471  "CAMELLIA", 256, "CAMELLIA-256-CBC",
472  0, 0, 0,
473 };
474 
475 /* tls_log_mask - Convert user TLS loglevel to internal log feature mask */
476 
477 int tls_log_mask(const char *log_param, const char *log_level)
478 {
479  int mask;
480 
481  mask = name_mask_opt(log_param, tls_log_table, log_level,
483  return (mask);
484 }
485 
486 /* tls_update_app_logmask - update log level after init */
487 
488 void tls_update_app_logmask(TLS_APPL_STATE *app_ctx, int log_mask)
489 {
490  app_ctx->log_mask = log_mask;
491 }
492 
493 /* tls_exclude_missing - Append exclusions for missing ciphers */
494 
495 static const char *tls_exclude_missing(SSL_CTX *ctx, VSTRING *buf)
496 {
497  const char *myname = "tls_exclude_missing";
498  static ARGV *exclude; /* Cached */
499  SSL *s = 0;
500  ssl_cipher_stack_t *ciphers;
501  const SSL_CIPHER *c;
502  const cipher_probe_t *probe;
503  int alg_bits;
504  int num;
505  int i;
506 
507  /*
508  * Process a list of probes which specify:
509  *
510  * An SSL cipher-suite name for a family of ciphers that use the same
511  * symmetric algorithm at two or more key sizes, typically 128/256 bits.
512  *
513  * The key size (typically 256) that OpenSSL fails to check, and assumes
514  * available when another key size (typically 128) is usable.
515  *
516  * The OpenSSL name of the symmetric algorithm associated with the SSL
517  * cipher-suite. Typically, this is MUMBLE-256-CBC, where "MUMBLE" is the
518  * name of the SSL cipher-suite that use the MUMBLE symmetric algorithm.
519  * On systems that support the required encryption algorithm, the name is
520  * listed in the output of "openssl list-cipher-algorithms".
521  *
522  * When an encryption algorithm is not available at the given key size but
523  * the corresponding OpenSSL cipher-suite contains ciphers that have have
524  * this key size, the problem ciphers are explicitly disabled in Postfix.
525  * The list is cached in the static "exclude" array.
526  */
527  if (exclude == 0) {
528  exclude = argv_alloc(1);
529 
530  /*
531  * Iterate over the probe list
532  */
533  for (probe = cipher_probes; probe->ssl_name; ++probe) {
534  /* No exclusions if evp_name is a valid algorithm */
535  if (EVP_get_cipherbyname(probe->evp_name))
536  continue;
537 
538  /*
539  * Sadly there is no SSL_CTX_get_ciphers() interface, so we are
540  * forced to allocate and free an SSL object. Fatal error if we
541  * can't allocate the SSL object.
542  */
543  ERR_clear_error();
544  if (s == 0 && (s = SSL_new(ctx)) == 0) {
545  tls_print_errors();
546  msg_fatal("%s: error allocating SSL object", myname);
547  }
548 
549  /*
550  * Cipher is not supported by libcrypto, nothing to do if also
551  * not supported by libssl. Flush the OpenSSL error stack.
552  *
553  * XXX: There may be additional places in pre-existing code where
554  * SSL errors are generated and ignored, that require a similar
555  * "flush". Better yet, is to always flush before calls that run
556  * tls_print_errors() on failure.
557  *
558  * Contrary to documentation, on SunOS 5.10 SSL_set_cipher_list()
559  * returns success with no ciphers selected, when this happens
560  * SSL_get_ciphers() produces a stack with 0 elements!
561  */
562  if (SSL_set_cipher_list(s, probe->ssl_name) == 0
563  || (ciphers = SSL_get_ciphers(s)) == 0
564  || (num = sk_SSL_CIPHER_num(ciphers)) == 0) {
565  ERR_clear_error(); /* flush any generated errors */
566  continue;
567  }
568  for (i = 0; i < num; ++i) {
569  c = sk_SSL_CIPHER_value(ciphers, i);
570  (void) SSL_CIPHER_get_bits(c, &alg_bits);
571  if (alg_bits == probe->alg_bits)
572  argv_add(exclude, SSL_CIPHER_get_name(c), ARGV_END);
573  }
574  }
575  if (s != 0)
576  SSL_free(s);
577  }
578  for (i = 0; i < exclude->argc; ++i)
579  vstring_sprintf_append(buf, ":!%s", exclude->argv[i]);
580  return (vstring_str(buf));
581 }
582 
583 /* tls_apply_cipher_list - update SSL_CTX cipher list */
584 
585 static const char *tls_apply_cipher_list(TLS_APPL_STATE *app_ctx,
586  const char *context, VSTRING *spec)
587 {
588  const char *new = tls_exclude_missing(app_ctx->ssl_ctx, spec);
589 
590  ERR_clear_error();
591  if (SSL_CTX_set_cipher_list(app_ctx->ssl_ctx, new) == 0) {
592  tls_print_errors();
593  vstring_sprintf(app_ctx->why, "invalid %s cipher list: \"%s\"",
594  context, new);
595  return (0);
596  }
597  return (new);
598 }
599 
600 /* tls_protocol_mask - Bitmask of protocols to exclude */
601 
602 int tls_protocol_mask(const char *plist)
603 {
604  char *save;
605  char *tok;
606  char *cp;
607  int code;
608  int exclude = 0;
609  int include = 0;
610 
611 #define FREE_AND_RETURN(ptr, res) do { \
612  myfree(ptr); \
613  return (res); \
614  } while (0)
615 
616  save = cp = mystrdup(plist);
617  while ((tok = mystrtok(&cp, CHARS_COMMA_SP ":")) != 0) {
618  if (*tok == '!')
619  exclude |= code =
620  name_code(protocol_table, NAME_CODE_FLAG_NONE, ++tok);
621  else
622  include |= code =
623  name_code(protocol_table, NAME_CODE_FLAG_NONE, tok);
624  if (code == TLS_PROTOCOL_INVALID)
625  FREE_AND_RETURN(save, TLS_PROTOCOL_INVALID);
626  }
627 
628  /*
629  * When the include list is empty, use only the explicit exclusions.
630  * Otherwise, also exclude the complement of the include list from the
631  * built-in list of known protocols. There is no way to exclude protocols
632  * we don't know about at compile time, and this is unavoidable because
633  * the OpenSSL API works with compile-time *exclusion* bit-masks.
634  */
635  FREE_AND_RETURN(save,
636  (include ? (exclude | (TLS_KNOWN_PROTOCOLS & ~include)) : exclude));
637 }
638 
639 /* tls_param_init - Load TLS related config parameters */
640 
641 void tls_param_init(void)
642 {
643  static const CONFIG_STR_TABLE str_table[] = {
658  VAR_OPENSSL_PATH, DEF_OPENSSL_PATH, &var_openssl_path, 1, 0,
659  0,
660  };
661  static const CONFIG_INT_TABLE int_table[] = {
663  0,
664  };
665  static const CONFIG_BOOL_TABLE bool_table[] = {
671  0,
672  };
673  static int init_done;
674 
675  if (init_done)
676  return;
677  init_done = 1;
678 
679  get_mail_conf_str_table(str_table);
680  get_mail_conf_int_table(int_table);
681  get_mail_conf_bool_table(bool_table);
682 }
683 
684 /* tls_set_ciphers - Set SSL context cipher list */
685 
686 const char *tls_set_ciphers(TLS_APPL_STATE *app_ctx, const char *context,
687  const char *grade, const char *exclusions)
688 {
689  const char *myname = "tls_set_ciphers";
690  static VSTRING *buf;
691  int new_grade;
692  char *save;
693  char *cp;
694  char *tok;
695  const char *new_list;
696 
697  new_grade = tls_cipher_grade(grade);
698  if (new_grade == TLS_CIPHER_NONE) {
699  vstring_sprintf(app_ctx->why, "invalid %s cipher grade: \"%s\"",
700  context, grade);
701  return (0);
702  }
703  if (buf == 0)
704  buf = vstring_alloc(10);
705  VSTRING_RESET(buf);
706 
707  /*
708  * Given cached state and identical input, we return the same result.
709  */
710  if (app_ctx->cipher_list) {
711  if (new_grade == app_ctx->cipher_grade
712  && strcmp(app_ctx->cipher_exclusions, exclusions) == 0)
713  return (app_ctx->cipher_list);
714 
715  /* Change required, flush cached state */
716  app_ctx->cipher_grade = TLS_CIPHER_NONE;
717 
718  myfree(app_ctx->cipher_exclusions);
719  app_ctx->cipher_exclusions = 0;
720 
721  myfree(app_ctx->cipher_list);
722  app_ctx->cipher_list = 0;
723  }
724  switch (new_grade) {
725  case TLS_CIPHER_HIGH:
727  break;
728  case TLS_CIPHER_MEDIUM:
730  break;
731  case TLS_CIPHER_LOW:
733  break;
734  case TLS_CIPHER_EXPORT:
736  break;
737  case TLS_CIPHER_NULL:
739  break;
740  default:
741 
742  /*
743  * The caller MUST provide a valid cipher grade
744  */
745  msg_panic("invalid %s cipher grade: %d", context, new_grade);
746  }
747 
748  /*
749  * The base lists for each grade can't be empty.
750  */
751  if (VSTRING_LEN(buf) == 0)
752  msg_panic("%s: empty \"%s\" cipherlist", myname, grade);
753 
754  /*
755  * Apply locally-specified exclusions.
756  */
757 #define CIPHER_SEP CHARS_COMMA_SP ":"
758  if (exclusions != 0) {
759  cp = save = mystrdup(exclusions);
760  while ((tok = mystrtok(&cp, CIPHER_SEP)) != 0) {
761 
762  /*
763  * Can't exclude ciphers that start with modifiers.
764  */
765  if (strchr("!+-@", *tok)) {
766  vstring_sprintf(app_ctx->why,
767  "invalid unary '!+-@' in %s cipher "
768  "exclusion: \"%s\"", context, tok);
769  return (0);
770  }
771  vstring_sprintf_append(buf, ":!%s", tok);
772  }
773  myfree(save);
774  }
775  if ((new_list = tls_apply_cipher_list(app_ctx, context, buf)) == 0)
776  return (0);
777 
778  /* Cache new state */
779  app_ctx->cipher_grade = new_grade;
780  app_ctx->cipher_exclusions = mystrdup(exclusions);
781 
782  return (app_ctx->cipher_list = mystrdup(new_list));
783 }
784 
785 /* tls_alloc_app_context - allocate TLS application context */
786 
787 TLS_APPL_STATE *tls_alloc_app_context(SSL_CTX *ssl_ctx, int log_mask)
788 {
789  TLS_APPL_STATE *app_ctx;
790 
791  app_ctx = (TLS_APPL_STATE *) mymalloc(sizeof(*app_ctx));
792 
793  /* See portability note below with other memset() call. */
794  memset((void *) app_ctx, 0, sizeof(*app_ctx));
795  app_ctx->ssl_ctx = ssl_ctx;
796  app_ctx->log_mask = log_mask;
797 
798  /* See also: cache purging code in tls_set_ciphers(). */
799  app_ctx->cipher_grade = TLS_CIPHER_NONE;
800  app_ctx->cipher_exclusions = 0;
801  app_ctx->cipher_list = 0;
802  app_ctx->cache_type = 0;
803  app_ctx->why = vstring_alloc(1);
804 
805  return (app_ctx);
806 }
807 
808 /* tls_free_app_context - Free TLS application context */
809 
810 void tls_free_app_context(TLS_APPL_STATE *app_ctx)
811 {
812  if (app_ctx->ssl_ctx)
813  SSL_CTX_free(app_ctx->ssl_ctx);
814  if (app_ctx->cache_type)
815  myfree(app_ctx->cache_type);
816  /* See also: cache purging code in tls_set_ciphers(). */
817  if (app_ctx->cipher_exclusions)
818  myfree(app_ctx->cipher_exclusions);
819  if (app_ctx->cipher_list)
820  myfree(app_ctx->cipher_list);
821  if (app_ctx->why)
822  vstring_free(app_ctx->why);
823  myfree((void *) app_ctx);
824 }
825 
826 /* tls_alloc_sess_context - allocate TLS session context */
827 
828 TLS_SESS_STATE *tls_alloc_sess_context(int log_mask, const char *namaddr)
829 {
830  TLS_SESS_STATE *TLScontext;
831 
832  /*
833  * PORTABILITY: Do not assume that null pointers are all-zero bits. Use
834  * explicit assignments to initialize pointers.
835  *
836  * See the C language FAQ item 5.17, or if you have time to burn,
837  * http://www.google.com/search?q=zero+bit+null+pointer
838  *
839  * However, it's OK to use memset() to zero integer values.
840  */
841  TLScontext = (TLS_SESS_STATE *) mymalloc(sizeof(TLS_SESS_STATE));
842  memset((void *) TLScontext, 0, sizeof(*TLScontext));
843  TLScontext->con = 0;
844  TLScontext->cache_type = 0;
845  TLScontext->serverid = 0;
846  TLScontext->peer_CN = 0;
847  TLScontext->issuer_CN = 0;
848  TLScontext->peer_cert_fprint = 0;
849  TLScontext->peer_pkey_fprint = 0;
850  TLScontext->protocol = 0;
851  TLScontext->cipher_name = 0;
852  TLScontext->log_mask = log_mask;
853  TLScontext->namaddr = lowercase(mystrdup(namaddr));
854  TLScontext->mdalg = 0; /* Alias for props->mdalg */
855  TLScontext->dane = 0; /* Alias for props->dane */
856  TLScontext->errordepth = -1;
857  TLScontext->tadepth = -1;
858  TLScontext->errorcode = X509_V_OK;
859  TLScontext->errorcert = 0;
860  TLScontext->untrusted = 0;
861  TLScontext->trusted = 0;
862 
863  return (TLScontext);
864 }
865 
866 /* tls_free_context - deallocate TLScontext and members */
867 
868 void tls_free_context(TLS_SESS_STATE *TLScontext)
869 {
870 
871  /*
872  * Free the SSL structure and the BIOs. Warning: the internal_bio is
873  * connected to the SSL structure and is automatically freed with it. Do
874  * not free it again (core dump)!! Only free the network_bio.
875  */
876  if (TLScontext->con != 0)
877  SSL_free(TLScontext->con);
878 
879  if (TLScontext->namaddr)
880  myfree(TLScontext->namaddr);
881  if (TLScontext->serverid)
882  myfree(TLScontext->serverid);
883 
884  if (TLScontext->peer_CN)
885  myfree(TLScontext->peer_CN);
886  if (TLScontext->issuer_CN)
887  myfree(TLScontext->issuer_CN);
888  if (TLScontext->peer_cert_fprint)
889  myfree(TLScontext->peer_cert_fprint);
890  if (TLScontext->peer_pkey_fprint)
891  myfree(TLScontext->peer_pkey_fprint);
892  if (TLScontext->errorcert)
893  X509_free(TLScontext->errorcert);
894  if (TLScontext->untrusted)
895  sk_X509_pop_free(TLScontext->untrusted, X509_free);
896  if (TLScontext->trusted)
897  sk_X509_pop_free(TLScontext->trusted, X509_free);
898 
899  myfree((void *) TLScontext);
900 }
901 
902 /* tls_version_split - Split OpenSSL version number into major, minor, ... */
903 
904 static void tls_version_split(unsigned long version, TLS_VINFO *info)
905 {
906 
907  /*
908  * OPENSSL_VERSION_NUMBER(3):
909  *
910  * OPENSSL_VERSION_NUMBER is a numeric release version identifier:
911  *
912  * MMNNFFPPS: major minor fix patch status
913  *
914  * The status nibble has one of the values 0 for development, 1 to e for
915  * betas 1 to 14, and f for release. Parsed OpenSSL version number. for
916  * example
917  *
918  * 0x000906000 == 0.9.6 dev 0x000906023 == 0.9.6b beta 3 0x00090605f ==
919  * 0.9.6e release
920  *
921  * Versions prior to 0.9.3 have identifiers < 0x0930. Versions between
922  * 0.9.3 and 0.9.5 had a version identifier with this interpretation:
923  *
924  * MMNNFFRBB major minor fix final beta/patch
925  *
926  * for example
927  *
928  * 0x000904100 == 0.9.4 release 0x000905000 == 0.9.5 dev
929  *
930  * Version 0.9.5a had an interim interpretation that is like the current
931  * one, except the patch level got the highest bit set, to keep continu-
932  * ity. The number was therefore 0x0090581f.
933  */
934 
935  if (version < 0x0930) {
936  info->status = 0;
937  info->patch = version & 0x0f;
938  version >>= 4;
939  info->micro = version & 0x0f;
940  version >>= 4;
941  info->minor = version & 0x0f;
942  version >>= 4;
943  info->major = version & 0x0f;
944  } else if (version < 0x00905800L) {
945  info->patch = version & 0xff;
946  version >>= 8;
947  info->status = version & 0xf;
948  version >>= 4;
949  info->micro = version & 0xff;
950  version >>= 8;
951  info->minor = version & 0xff;
952  version >>= 8;
953  info->major = version & 0xff;
954  } else {
955  info->status = version & 0xf;
956  version >>= 4;
957  info->patch = version & 0xff;
958  version >>= 8;
959  info->micro = version & 0xff;
960  version >>= 8;
961  info->minor = version & 0xff;
962  version >>= 8;
963  info->major = version & 0xff;
964  if (version < 0x00906000L)
965  info->patch &= ~0x80;
966  }
967 }
968 
969 /* tls_check_version - Detect mismatch between headers and library. */
970 
971 void tls_check_version(void)
972 {
973  TLS_VINFO hdr_info;
974  TLS_VINFO lib_info;
975 
976  tls_version_split(OPENSSL_VERSION_NUMBER, &hdr_info);
977  tls_version_split(OpenSSL_version_num(), &lib_info);
978 
979  if (lib_info.major != hdr_info.major
980  || lib_info.minor != hdr_info.minor
981  || lib_info.micro != hdr_info.micro)
982  msg_warn("run-time library vs. compile-time header version mismatch: "
983  "OpenSSL %d.%d.%d may not be compatible with OpenSSL %d.%d.%d",
984  lib_info.major, lib_info.minor, lib_info.micro,
985  hdr_info.major, hdr_info.minor, hdr_info.micro);
986 }
987 
988 /* tls_compile_version - compile-time OpenSSL version */
989 
990 const char *tls_compile_version(void)
991 {
992  return (OPENSSL_VERSION_TEXT);
993 }
994 
995 /* tls_run_version - run-time version "major.minor.micro" */
996 
997 const char *tls_run_version(void)
998 {
999  return (OpenSSL_version(OPENSSL_VERSION));
1000 }
1001 
1002 const char **tls_pkey_algorithms(void)
1003 {
1004 
1005  /*
1006  * Return an array, not string, so that the result can be inspected
1007  * without parsing. Sort the result alphabetically, not chronologically.
1008  */
1009  static const char *algs[] = {
1010 #ifndef OPENSSL_NO_DSA
1011  "dsa",
1012 #endif
1013 #if OPENSSL_VERSION_NUMBER >= 0x10000000L && !defined(OPENSSL_NO_ECDSA)
1014  "ecdsa",
1015 #endif
1016 #ifndef OPENSSL_NO_RSA
1017  "rsa",
1018 #endif
1019  0,
1020  };
1021 
1022  return (algs);
1023 }
1024 
1025 /* tls_bug_bits - SSL bug compatibility bits for this OpenSSL version */
1026 
1027 long tls_bug_bits(void)
1028 {
1029  long bits = SSL_OP_ALL; /* Work around all known bugs */
1030 
1031 #if OPENSSL_VERSION_NUMBER >= 0x00908000L && \
1032  OPENSSL_VERSION_NUMBER < 0x10000000L
1033  long lib_version = OpenSSL_version_num();
1034 
1035  /*
1036  * In OpenSSL 0.9.8[ab], enabling zlib compression breaks the padding bug
1037  * work-around, leading to false positives and failed connections. We may
1038  * not interoperate with systems with the bug, but this is better than
1039  * breaking on all 0.9.8[ab] systems that have zlib support enabled.
1040  */
1041  if (lib_version >= 0x00908000L && lib_version <= 0x0090802fL) {
1042  ssl_comp_stack_t *comp_methods = SSL_COMP_get_compression_methods();
1043 
1044  comp_methods = SSL_COMP_get_compression_methods();
1045  if (comp_methods != 0 && sk_SSL_COMP_num(comp_methods) > 0)
1046  bits &= ~SSL_OP_TLS_BLOCK_PADDING_BUG;
1047  }
1048 #endif
1049 
1050  /*
1051  * Silently ignore any strings that don't appear in the tweaks table, or
1052  * hex bits that are not in SSL_OP_ALL.
1053  */
1054  if (*var_tls_bug_tweaks) {
1055  bits &= ~long_name_mask_opt(VAR_TLS_BUG_TWEAKS, ssl_bug_tweaks,
1058 #ifdef SSL_OP_SAFARI_ECDHE_ECDSA_BUG
1059  /* Not relevant to SMTP */
1060  bits &= ~SSL_OP_SAFARI_ECDHE_ECDSA_BUG;
1061 #endif
1062  }
1063 
1064  /*
1065  * Allow users to set options not in SSL_OP_ALL, and not already managed
1066  * via other Postfix parameters.
1067  */
1068  if (*var_tls_ssl_options) {
1069  long enable;
1070 
1071  enable = long_name_mask_opt(VAR_TLS_SSL_OPTIONS, ssl_op_tweaks,
1074  enable &= ~(SSL_OP_ALL | TLS_SSL_OP_MANAGED_BITS);
1075  bits |= enable;
1076  }
1077 
1078  /*
1079  * We unconditionally avoid re-use of ephemeral keys, note that we set DH
1080  * keys via a callback, so reuse was never possible, but the ECDH key is
1081  * set statically, so that is potentially subject to reuse. Set both
1082  * options just in case.
1083  */
1084  bits |= SSL_OP_SINGLE_ECDH_USE | SSL_OP_SINGLE_DH_USE;
1085  return (bits);
1086 }
1087 
1088 /* tls_print_errors - print and clear the error stack */
1089 
1090 void tls_print_errors(void)
1091 {
1092  unsigned long err;
1093  char buffer[1024]; /* XXX */
1094  const char *file;
1095  const char *data;
1096  int line;
1097  int flags;
1098 
1099  while ((err = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) {
1100  ERR_error_string_n(err, buffer, sizeof(buffer));
1101  if (flags & ERR_TXT_STRING)
1102  msg_warn("TLS library problem: %s:%s:%d:%s:",
1103  buffer, file, line, data);
1104  else
1105  msg_warn("TLS library problem: %s:%s:%d:", buffer, file, line);
1106  }
1107 }
1108 
1109 /* tls_info_callback - callback for logging SSL events via Postfix */
1110 
1111 void tls_info_callback(const SSL *s, int where, int ret)
1112 {
1113  char *str;
1114  int w;
1115 
1116  /* Adapted from OpenSSL apps/s_cb.c. */
1117 
1118  w = where & ~SSL_ST_MASK;
1119 
1120  if (w & SSL_ST_CONNECT)
1121  str = "SSL_connect";
1122  else if (w & SSL_ST_ACCEPT)
1123  str = "SSL_accept";
1124  else
1125  str = "unknown";
1126 
1127  if (where & SSL_CB_LOOP) {
1128  msg_info("%s:%s", str, SSL_state_string_long((SSL *) s));
1129  } else if (where & SSL_CB_ALERT) {
1130  str = (where & SSL_CB_READ) ? "read" : "write";
1131  if ((ret & 0xff) != SSL3_AD_CLOSE_NOTIFY)
1132  msg_info("SSL3 alert %s:%s:%s", str,
1133  SSL_alert_type_string_long(ret),
1134  SSL_alert_desc_string_long(ret));
1135  } else if (where & SSL_CB_EXIT) {
1136  if (ret == 0)
1137  msg_info("%s:failed in %s",
1138  str, SSL_state_string_long((SSL *) s));
1139  else if (ret < 0) {
1140 #ifndef LOG_NON_ERROR_STATES
1141  switch (SSL_get_error((SSL *) s, ret)) {
1142  case SSL_ERROR_WANT_READ:
1143  case SSL_ERROR_WANT_WRITE:
1144  /* Don't log non-error states. */
1145  break;
1146  default:
1147 #endif
1148  msg_info("%s:error in %s",
1149  str, SSL_state_string_long((SSL *) s));
1150 #ifndef LOG_NON_ERROR_STATES
1151  }
1152 #endif
1153  }
1154  }
1155 }
1156 
1157  /*
1158  * taken from OpenSSL crypto/bio/b_dump.c.
1159  *
1160  * Modified to save a lot of strcpy and strcat by Matti Aarnio.
1161  *
1162  * Rewritten by Wietse to elimate fixed-size stack buffer, array index
1163  * multiplication and division, sprintf() and strcpy(), and lots of strlen()
1164  * calls. We could make it a little faster by using a fixed-size stack-based
1165  * buffer.
1166  *
1167  * 200412 - use %lx to print pointers, after casting them to unsigned long.
1168  */
1169 
1170 #define TRUNCATE_SPACE_NULL
1171 #define DUMP_WIDTH 16
1172 #define VERT_SPLIT 7
1173 
1174 static void tls_dump_buffer(const unsigned char *start, int len)
1175 {
1176  VSTRING *buf = vstring_alloc(100);
1177  const unsigned char *last = start + len - 1;
1178  const unsigned char *row;
1179  const unsigned char *col;
1180  int ch;
1181 
1182 #ifdef TRUNCATE_SPACE_NULL
1183  while (last >= start && (*last == ' ' || *last == 0))
1184  last--;
1185 #endif
1186 
1187  for (row = start; row <= last; row += DUMP_WIDTH) {
1188  VSTRING_RESET(buf);
1189  vstring_sprintf(buf, "%04lx ", (unsigned long) (row - start));
1190  for (col = row; col < row + DUMP_WIDTH; col++) {
1191  if (col > last) {
1192  vstring_strcat(buf, " ");
1193  } else {
1194  ch = *col;
1195  vstring_sprintf_append(buf, "%02x%c",
1196  ch, col - row == VERT_SPLIT ? '|' : ' ');
1197  }
1198  }
1199  VSTRING_ADDCH(buf, ' ');
1200  for (col = row; col < row + DUMP_WIDTH; col++) {
1201  if (col > last)
1202  break;
1203  ch = *col;
1204  if (!ISPRINT(ch))
1205  ch = '.';
1206  VSTRING_ADDCH(buf, ch);
1207  if (col - row == VERT_SPLIT)
1208  VSTRING_ADDCH(buf, ' ');
1209  }
1210  VSTRING_TERMINATE(buf);
1211  msg_info("%s", vstring_str(buf));
1212  }
1213 #ifdef TRUNCATE_SPACE_NULL
1214  if ((last + 1) - start < len)
1215  msg_info("%04lx - <SPACES/NULLS>",
1216  (unsigned long) ((last + 1) - start));
1217 #endif
1218  vstring_free(buf);
1219 }
1220 
1221 /* taken from OpenSSL apps/s_cb.c */
1222 
1223 long tls_bio_dump_cb(BIO *bio, int cmd, const char *argp, int argi,
1224  long unused_argl, long ret)
1225 {
1226  if (cmd == (BIO_CB_READ | BIO_CB_RETURN)) {
1227  msg_info("read from %08lX [%08lX] (%d bytes => %ld (0x%lX))",
1228  (unsigned long) bio, (unsigned long) argp, argi,
1229  ret, (unsigned long) ret);
1230  tls_dump_buffer((unsigned char *) argp, (int) ret);
1231  } else if (cmd == (BIO_CB_WRITE | BIO_CB_RETURN)) {
1232  msg_info("write to %08lX [%08lX] (%d bytes => %ld (0x%lX))",
1233  (unsigned long) bio, (unsigned long) argp, argi,
1234  ret, (unsigned long) ret);
1235  tls_dump_buffer((unsigned char *) argp, (int) ret);
1236  }
1237  return (ret);
1238 }
1239 
1240 int tls_validate_digest(const char *dgst)
1241 {
1242  const EVP_MD *md_alg;
1243  unsigned int md_len;
1244 
1245  /*
1246  * Register SHA-2 digests, if implemented and not already registered.
1247  * Improves interoperability with clients and servers that prematurely
1248  * deploy SHA-2 certificates. Also facilitates DANE and TA support.
1249  */
1250 #if defined(LN_sha256) && defined(NID_sha256) && !defined(OPENSSL_NO_SHA256)
1251  if (!EVP_get_digestbyname(LN_sha224))
1252  EVP_add_digest(EVP_sha224());
1253  if (!EVP_get_digestbyname(LN_sha256))
1254  EVP_add_digest(EVP_sha256());
1255 #endif
1256 #if defined(LN_sha512) && defined(NID_sha512) && !defined(OPENSSL_NO_SHA512)
1257  if (!EVP_get_digestbyname(LN_sha384))
1258  EVP_add_digest(EVP_sha384());
1259  if (!EVP_get_digestbyname(LN_sha512))
1260  EVP_add_digest(EVP_sha512());
1261 #endif
1262 
1263  /*
1264  * If the administrator specifies an unsupported digest algorithm, fail
1265  * now, rather than in the middle of a TLS handshake.
1266  */
1267  if ((md_alg = EVP_get_digestbyname(dgst)) == 0) {
1268  msg_warn("Digest algorithm \"%s\" not found", dgst);
1269  return (0);
1270  }
1271 
1272  /*
1273  * Sanity check: Newer shared libraries may use larger digests.
1274  */
1275  if ((md_len = EVP_MD_size(md_alg)) > EVP_MAX_MD_SIZE) {
1276  msg_warn("Digest algorithm \"%s\" output size %u too large",
1277  dgst, md_len);
1278  return (0);
1279  }
1280  return (1);
1281 }
1282 
1283 #else
1284 
1285  /*
1286  * Broken linker workaround.
1287  */
1289 
1290 #endif
#define DEF_TLS_DANE_DIGESTS
Definition: mail_params.h:3327
char * var_tls_eecdh_auto
#define DEF_TLS_MEDIUM_CLIST
Definition: mail_params.h:3220
void myfree(void *ptr)
Definition: mymalloc.c:207
char * var_tls_bug_tweaks
#define DEF_TLS_NULL_CLIST
Definition: mail_params.h:3232
#define DEF_TLS_APPEND_DEF_CA
Definition: mail_params.h:698
#define ARGV_END
Definition: argv.h:52
#define VAR_TLS_EXPORT_CLIST
Definition: mail_params.h:3227
#define DEF_TLS_SSL_OPTIONS
Definition: mail_params.h:3302
char * var_tls_eecdh_ultra
char * mystrdup(const char *str)
Definition: mymalloc.c:225
#define DEF_TLS_LOW_CLIST
Definition: mail_params.h:3224
char * var_tls_tkt_cipher
Definition: argv.h:17
NORETURN msg_panic(const char *fmt,...)
Definition: msg.c:295
#define DEF_TLS_HIGH_CLIST
Definition: mail_params.h:3216
#define DEF_TLS_BC_PKEY_FPRINT
Definition: mail_params.h:3310
#define vstring_str(vp)
Definition: vstring.h:71
char * var_tls_medium_clist
#define VAR_TLS_DANE_AGILITY
Definition: mail_params.h:3319
#define VAR_TLS_EECDH_AUTO
Definition: mail_params.h:3261
#define DEF_TLS_BUG_TWEAKS
Definition: mail_params.h:3298
char ** argv
Definition: argv.h:20
int tls_dummy_for_broken_linkers
Definition: tls_misc.c:1288
bool var_tls_dane_taa_dgst
char * var_tls_ssl_options
#define VAR_TLS_MGR_SERVICE
Definition: mail_params.h:693
void argv_add(ARGV *argvp,...)
Definition: argv.c:197
#define VAR_TLS_HIGH_CLIST
Definition: mail_params.h:3215
char * var_tls_export_clist
char * mystrtok(char **src, const char *sep)
Definition: mystrtok.c:54
#define DEF_TLS_DAEMON_RAND_BYTES
Definition: mail_params.h:718
ARGV * argv_alloc(ssize_t len)
Definition: argv.c:149
#define VAR_TLS_PREEMPT_CLIST
Definition: mail_params.h:3277
#define VSTRING_LEN(vp)
Definition: vstring.h:72
#define DEF_TLS_EECDH_AUTO
Definition: mail_params.h:3262
#define VAR_TLS_MEDIUM_CLIST
Definition: mail_params.h:3219
#define VAR_TLS_EECDH_STRONG
Definition: mail_params.h:3269
VSTRING * vstring_strcpy(VSTRING *vp, const char *src)
Definition: vstring.c:431
#define VSTRING_TERMINATE(vp)
Definition: vstring.h:74
char * var_tls_mgr_service
#define VAR_TLS_DANE_DIGESTS
Definition: mail_params.h:3326
#define VSTRING_ADDCH(vp, ch)
Definition: vstring.h:81
VSTRING * vstring_sprintf_append(VSTRING *vp, const char *format,...)
Definition: vstring.c:624
#define VAR_TLS_BUG_TWEAKS
Definition: mail_params.h:3297
#define DEF_TLS_EECDH_STRONG
Definition: mail_params.h:3270
#define DEF_TLS_PREEMPT_CLIST
Definition: mail_params.h:3278
bool var_tls_bc_pkey_fprint
#define VAR_TLS_NULL_CLIST
Definition: mail_params.h:3231
char * var_tls_low_clist
#define DEF_TLS_EECDH_ULTRA
Definition: mail_params.h:3274
#define DEF_TLS_MGR_SERVICE
Definition: mail_params.h:694
#define VSTRING_RESET(vp)
Definition: vstring.h:77
void msg_warn(const char *fmt,...)
Definition: msg.c:215
#define VAR_TLS_LOW_CLIST
Definition: mail_params.h:3223
VSTRING * vstring_alloc(ssize_t len)
Definition: vstring.c:353
#define VAR_TLS_MULTI_WILDCARD
Definition: mail_params.h:3281
#define NAME_CODE_FLAG_NONE
Definition: name_code.h:22
#define DEF_TLS_DANE_TAA_DGST
Definition: mail_params.h:3336
int var_tls_daemon_rand_bytes
#define NAME_MASK_RETURN
Definition: name_mask.h:29
#define DEF_TLS_DANE_AGILITY
Definition: mail_params.h:3320
VSTRING * vstring_sprintf(VSTRING *vp, const char *format,...)
Definition: vstring.c:602
#define DEF_TLS_MULTI_WILDCARD
Definition: mail_params.h:3282
char * lowercase(char *string)
Definition: lowercase.c:34
void get_mail_conf_str_table(const CONFIG_STR_TABLE *)
int name_code(const NAME_CODE *table, int flags, const char *name)
Definition: name_code.c:65
#define VAR_TLS_BC_PKEY_FPRINT
Definition: mail_params.h:3309
#define VAR_TLS_TKT_CIPHER
Definition: mail_params.h:3305
NORETURN msg_fatal(const char *fmt,...)
Definition: msg.c:249
void get_mail_conf_bool_table(const CONFIG_BOOL_TABLE *)
#define DEF_OPENSSL_PATH
Definition: mail_params.h:2677
#define CHARS_COMMA_SP
Definition: sys_defs.h:1761
#define VAR_TLS_APPEND_DEF_CA
Definition: mail_params.h:697
bool var_tls_preempt_clist
#define VAR_TLS_SSL_OPTIONS
Definition: mail_params.h:3301
#define ISPRINT(c)
Definition: sys_defs.h:1751
char * var_tls_dane_digests
#define DEF_TLS_EXPORT_CLIST
Definition: mail_params.h:3228
#define VAR_TLS_EECDH_ULTRA
Definition: mail_params.h:3273
char * var_tls_high_clist
VSTRING * vstring_free(VSTRING *vp)
Definition: vstring.c:380
#define NAME_MASK_NUMBER
Definition: name_mask.h:32
#define long_name_mask_opt(tag, table, str, flags)
Definition: name_mask.h:65
#define DEF_TLS_TKT_CIPHER
Definition: mail_params.h:3306
char * var_tls_eecdh_strong
#define VAR_TLS_DAEMON_RAND_BYTES
Definition: mail_params.h:717
void get_mail_conf_int_table(const CONFIG_INT_TABLE *)
#define VAR_OPENSSL_PATH
Definition: mail_params.h:2675
#define NAME_MASK_ANY_CASE
Definition: name_mask.h:28
bool var_tls_multi_wildcard
ssize_t argc
Definition: argv.h:19
#define NAME_MASK_WARN
Definition: name_mask.h:33
char * var_tls_dane_agility
#define VAR_TLS_DANE_TAA_DGST
Definition: mail_params.h:3335
char * var_tls_null_clist
#define name_mask_opt(tag, table, str, flags)
Definition: name_mask.h:46
bool var_tls_append_def_CA
VSTRING * vstring_strcat(VSTRING *vp, const char *src)
Definition: vstring.c:459
void * mymalloc(ssize_t len)
Definition: mymalloc.c:150
void msg_info(const char *fmt,...)
Definition: msg.c:199