SPDX: license tags (mostly by guesswork)
[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-only */
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 #include "tls.h"
16
17 /* Options specific to the tls authentication mechanism. */
18
19 optionlist auth_tls_options[] = {
20   { "server_param",     opt_stringptr,
21       OPT_OFF(auth_tls_options_block, server_param1) },
22   { "server_param1",    opt_stringptr,
23       OPT_OFF(auth_tls_options_block, server_param1) },
24   { "server_param2",    opt_stringptr,
25       OPT_OFF(auth_tls_options_block, server_param2) },
26   { "server_param3",    opt_stringptr,
27       OPT_OFF(auth_tls_options_block, server_param3) },
28 };
29
30 /* Size of the options list. An extern variable has to be used so that its
31 address can appear in the tables drtables.c. */
32
33 int auth_tls_options_count = nelem(auth_tls_options);
34
35 /* Default private options block for the authentication method. */
36
37 auth_tls_options_block auth_tls_option_defaults = {
38     NULL,       /* server_param1 */
39     NULL,       /* server_param2 */
40     NULL,       /* server_param3 */
41 };
42
43
44 #ifdef MACRO_PREDEF
45
46 /* Dummy values */
47 void auth_tls_init(auth_instance *ablock) {}
48 int auth_tls_server(auth_instance *ablock, uschar *data) {return 0;}
49 int auth_tls_client(auth_instance *ablock, void * sx,
50   int timeout, uschar *buffer, int buffsize) {return 0;}
51
52 #else   /*!MACRO_PREDEF*/
53
54
55
56
57 /*************************************************
58 *          Initialization entry point            *
59 *************************************************/
60
61 /* Called for each instance, after its options have been read, to
62 enable consistency checks to be done, or anything else that needs
63 to be set up. */
64
65 void
66 auth_tls_init(auth_instance *ablock)
67 {
68 ablock->public_name = ablock->name;     /* needed for core code */
69 }
70
71
72
73 /*************************************************
74 *             Server entry point                 *
75 *************************************************/
76
77 /* For interface, see auths/README */
78
79 int
80 auth_tls_server(auth_instance *ablock, uschar *data)
81 {
82 auth_tls_options_block * ob = (auth_tls_options_block *)ablock->options_block;
83
84 if (ob->server_param1)
85   auth_vars[expand_nmax++] = expand_string(ob->server_param1);
86 if (ob->server_param2)
87   auth_vars[expand_nmax++] = expand_string(ob->server_param2);
88 if (ob->server_param3)
89   auth_vars[expand_nmax++] = expand_string(ob->server_param3);
90 return auth_check_serv_cond(ablock);
91 }
92
93
94 #endif   /*!MACRO_PREDEF*/
95 /* End of tls.c */