Use compressed form of ipv6 in $sender_host_address under -bh. Bug 3027
[exim.git] / src / src / auths / tls.c
1 /*************************************************
2 *     Exim - an Internet mail transport agent    *
3 *************************************************/
4
5 /* Copyright (c) Jeremy Harris 1995 - 2020 */
6 /* See the file NOTICE for conditions of use and distribution. */
7 /* SPDX-License-Identifier: GPL-2.0-or-later */
8
9 /* This file provides an Exim authenticator driver for
10 a server to verify a client SSL certificate
11 */
12
13
14 #include "../exim.h"
15
16 #ifdef AUTH_TLS         /* Remainder of file */
17 #include "tls.h"
18
19 /* Options specific to the tls authentication mechanism. */
20
21 optionlist auth_tls_options[] = {
22   { "server_param",     opt_stringptr,
23       OPT_OFF(auth_tls_options_block, server_param1) },
24   { "server_param1",    opt_stringptr,
25       OPT_OFF(auth_tls_options_block, server_param1) },
26   { "server_param2",    opt_stringptr,
27       OPT_OFF(auth_tls_options_block, server_param2) },
28   { "server_param3",    opt_stringptr,
29       OPT_OFF(auth_tls_options_block, server_param3) },
30 };
31
32 /* Size of the options list. An extern variable has to be used so that its
33 address can appear in the tables drtables.c. */
34
35 int auth_tls_options_count = nelem(auth_tls_options);
36
37 /* Default private options block for the authentication method. */
38
39 auth_tls_options_block auth_tls_option_defaults = {
40     NULL,       /* server_param1 */
41     NULL,       /* server_param2 */
42     NULL,       /* server_param3 */
43 };
44
45
46 #ifdef MACRO_PREDEF
47
48 /* Dummy values */
49 void auth_tls_init(auth_instance *ablock) {}
50 int auth_tls_server(auth_instance *ablock, uschar *data) {return 0;}
51 int auth_tls_client(auth_instance *ablock, void * sx,
52   int timeout, uschar *buffer, int buffsize) {return 0;}
53
54 #else   /*!MACRO_PREDEF*/
55
56
57
58
59 /*************************************************
60 *          Initialization entry point            *
61 *************************************************/
62
63 /* Called for each instance, after its options have been read, to
64 enable consistency checks to be done, or anything else that needs
65 to be set up. */
66
67 void
68 auth_tls_init(auth_instance *ablock)
69 {
70 ablock->public_name = ablock->name;     /* needed for core code */
71 }
72
73
74
75 /*************************************************
76 *             Server entry point                 *
77 *************************************************/
78
79 /* For interface, see auths/README */
80
81 int
82 auth_tls_server(auth_instance *ablock, uschar *data)
83 {
84 auth_tls_options_block * ob = (auth_tls_options_block *)ablock->options_block;
85
86 if (ob->server_param1)
87   auth_vars[expand_nmax++] = expand_string(ob->server_param1);
88 if (ob->server_param2)
89   auth_vars[expand_nmax++] = expand_string(ob->server_param2);
90 if (ob->server_param3)
91   auth_vars[expand_nmax++] = expand_string(ob->server_param3);
92 return auth_check_serv_cond(ablock);
93 }
94
95
96 #endif  /*!MACRO_PREDEF*/
97 #endif  /*AUTH_TLS*/
98 /* End of tls.c */