1 /*++
2 /* NAME
3 /* tls_proxy_client_misc 3
4 /* SUMMARY
5 /* TLS_CLIENT_XXX structure support
6 /* SYNOPSIS
7 /* #include <tls_proxy.h>
8 /*
9 /* TLS_CLIENT_PARAMS *tls_proxy_client_param_from_config(params)
10 /* TLS_CLIENT_PARAMS *params;
11 /*
12 /* char *tls_proxy_client_param_serialize(print_fn, buf, params)
13 /* ATTR_PRINT_COMMON_FN print_fn;
14 /* VSTRING *buf;
15 /* const TLS_CLIENT_PARAMS *params;
16 /*
17 /* char *tls_proxy_client_init_serialize(print_fn, buf, init_props)
18 /* ATTR_PRINT_COMMON_FN print_fn;
19 /* VSTRING *buf;
20 /* const TLS_CLIENT_INIT_PROPS *init_props;
21 /* DESCRIPTION
22 /* tls_proxy_client_param_from_config() initializes a TLS_CLIENT_PARAMS
23 /* structure from configuration parameters and returns its
24 /* argument. Strings are not copied. The result must therefore
25 /* not be passed to tls_proxy_client_param_free().
26 /*
27 /* tls_proxy_client_param_serialize() and
28 /* tls_proxy_client_init_serialize() serialize the specified
29 /* object to a memory buffer, using the specified print function
30 /* (typically, attr_print_plain). The result can be used
31 /* determine whether there are any differences between instances
32 /* of the same object type.
33 /* LICENSE
34 /* .ad
35 /* .fi
36 /* The Secure Mailer license must be distributed with this software.
37 /* AUTHOR(S)
38 /* Wietse Venema
39 /* Google, Inc.
40 /* 111 8th Avenue
41 /* New York, NY 10011, USA
42 /*--*/
43
44 #ifdef USE_TLS
45
46 /* System library. */
47
48 #include <sys_defs.h>
49
50 /* Utility library */
51
52 #include <attr.h>
53 #include <msg.h>
54
55 /* Global library. */
56
57 #include <mail_params.h>
58
59 /* TLS library. */
60
61 #include <tls.h>
62 #include <tls_proxy.h>
63
64 /* tls_proxy_client_param_from_config - initialize TLS_CLIENT_PARAMS from configuration */
65
tls_proxy_client_param_from_config(TLS_CLIENT_PARAMS * params)66 TLS_CLIENT_PARAMS *tls_proxy_client_param_from_config(TLS_CLIENT_PARAMS *params)
67 {
68 TLS_PROXY_PARAMS(params,
69 tls_high_clist = var_tls_high_clist,
70 tls_medium_clist = var_tls_medium_clist,
71 tls_low_clist = var_tls_low_clist,
72 tls_export_clist = var_tls_export_clist,
73 tls_null_clist = var_tls_null_clist,
74 tls_eecdh_auto = var_tls_eecdh_auto,
75 tls_eecdh_strong = var_tls_eecdh_strong,
76 tls_eecdh_ultra = var_tls_eecdh_ultra,
77 tls_bug_tweaks = var_tls_bug_tweaks,
78 tls_ssl_options = var_tls_ssl_options,
79 tls_dane_digests = var_tls_dane_digests,
80 tls_mgr_service = var_tls_mgr_service,
81 tls_tkt_cipher = var_tls_tkt_cipher,
82 tls_daemon_rand_bytes = var_tls_daemon_rand_bytes,
83 tls_append_def_CA = var_tls_append_def_CA,
84 tls_bc_pkey_fprint = var_tls_bc_pkey_fprint,
85 tls_preempt_clist = var_tls_preempt_clist,
86 tls_multi_wildcard = var_tls_multi_wildcard);
87 return (params);
88 }
89
90 /* tls_proxy_client_param_serialize - serialize TLS_CLIENT_PARAMS to string */
91
tls_proxy_client_param_serialize(ATTR_PRINT_COMMON_FN print_fn,VSTRING * buf,const TLS_CLIENT_PARAMS * params)92 char *tls_proxy_client_param_serialize(ATTR_PRINT_COMMON_FN print_fn,
93 VSTRING *buf,
94 const TLS_CLIENT_PARAMS *params)
95 {
96 const char myname[] = "tls_proxy_client_param_serialize";
97 VSTREAM *mp;
98
99 if ((mp = vstream_memopen(buf, O_WRONLY)) == 0
100 || print_fn(mp, ATTR_FLAG_NONE,
101 SEND_ATTR_FUNC(tls_proxy_client_param_print,
102 (const void *) params),
103 ATTR_TYPE_END) != 0
104 || vstream_fclose(mp) != 0)
105 msg_fatal("%s: can't serialize properties: %m", myname);
106 return (vstring_str(buf));
107 }
108
109 /* tls_proxy_client_init_serialize - serialize to string */
110
tls_proxy_client_init_serialize(ATTR_PRINT_COMMON_FN print_fn,VSTRING * buf,const TLS_CLIENT_INIT_PROPS * props)111 char *tls_proxy_client_init_serialize(ATTR_PRINT_COMMON_FN print_fn,
112 VSTRING *buf,
113 const TLS_CLIENT_INIT_PROPS *props)
114 {
115 const char myname[] = "tls_proxy_client_init_serialize";
116 VSTREAM *mp;
117
118 if ((mp = vstream_memopen(buf, O_WRONLY)) == 0
119 || print_fn(mp, ATTR_FLAG_NONE,
120 SEND_ATTR_FUNC(tls_proxy_client_init_print,
121 (const void *) props),
122 ATTR_TYPE_END) != 0
123 || vstream_fclose(mp) != 0)
124 msg_fatal("%s: can't serialize properties: %m", myname);
125 return (vstring_str(buf));
126 }
127
128 #endif
129