Import Upstream version 4.89
[hcoop/debian/exim4.git] / src / auths / tls.c
1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
4
5 /* Copyright (c) Jeremy Harris 2016 */
6 /* See the file NOTICE for conditions of use and distribution. */
7
8 /* This file provides an Exim authenticator driver for
9 a server to verify a client SSL certificate
10 */
11
12
13 #include "../exim.h"
14 #include "tls.h"
15
16 /* Options specific to the tls authentication mechanism. */
17
18 optionlist auth_tls_options[] = {
19 { "server_param", opt_stringptr,
20 (void *)(offsetof(auth_tls_options_block, server_param1)) },
21 { "server_param1", opt_stringptr,
22 (void *)(offsetof(auth_tls_options_block, server_param1)) },
23 { "server_param2", opt_stringptr,
24 (void *)(offsetof(auth_tls_options_block, server_param2)) },
25 { "server_param3", opt_stringptr,
26 (void *)(offsetof(auth_tls_options_block, server_param3)) },
27 };
28
29 /* Size of the options list. An extern variable has to be used so that its
30 address can appear in the tables drtables.c. */
31
32 int auth_tls_options_count = nelem(auth_tls_options);
33
34 /* Default private options block for the authentication method. */
35
36 auth_tls_options_block auth_tls_option_defaults = {
37 NULL, /* server_param1 */
38 NULL, /* server_param2 */
39 NULL, /* server_param3 */
40 };
41
42
43 /*************************************************
44 * Initialization entry point *
45 *************************************************/
46
47 /* Called for each instance, after its options have been read, to
48 enable consistency checks to be done, or anything else that needs
49 to be set up. */
50
51 void
52 auth_tls_init(auth_instance *ablock)
53 {
54 ablock->public_name = ablock->name; /* needed for core code */
55 }
56
57
58
59 /*************************************************
60 * Server entry point *
61 *************************************************/
62
63 /* For interface, see auths/README */
64
65 int
66 auth_tls_server(auth_instance *ablock, uschar *data)
67 {
68 auth_tls_options_block * ob = (auth_tls_options_block *)ablock->options_block;
69
70 if (ob->server_param1)
71 auth_vars[expand_nmax++] = expand_string(ob->server_param1);
72 if (ob->server_param2)
73 auth_vars[expand_nmax++] = expand_string(ob->server_param2);
74 if (ob->server_param3)
75 auth_vars[expand_nmax++] = expand_string(ob->server_param3);
76 return auth_check_serv_cond(ablock);
77 }
78
79
80 /* End of tls.c */