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