2 * OpenConnect (SSL + DTLS) VPN client
4 * Copyright © 2008-2010 Intel Corporation.
6 * Author: David Woodhouse <dwmw2@infradead.org>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1, as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to:
20 * Free Software Foundation, Inc.
21 * 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA
24 #include <openssl/ssl.h>
25 #include <openssl/ui.h>
27 /* OpenSSL UI method calls. These are just stubs, to show how it's done */
28 /* While we can set user data on the calls from the TPM setup, we can't
29 set it on the calls for PEM certificate passphrases, AFAICT. */
30 static int ui_open(UI *ui)
32 /* Fall through to default OpenSSL UI */
33 return UI_method_get_opener(UI_OpenSSL())(ui);
36 static int ui_read(UI *ui, UI_STRING *uis)
38 /* Fall through to default OpenSSL UI */
39 return UI_method_get_reader(UI_OpenSSL())(ui, uis);
41 static int ui_write(UI *ui, UI_STRING *uis)
43 /* Fall through to default OpenSSL UI */
44 return UI_method_get_writer(UI_OpenSSL())(ui, uis);
47 static int ui_close(UI *ui)
49 /* Fall through to default OpenSSL UI */
50 return UI_method_get_closer(UI_OpenSSL())(ui);
53 int set_openssl_ui(void)
55 UI_METHOD *ui_method = UI_create_method("AnyConnect VPN UI");
57 /* Set up a UI method of our own for password/passphrase requests */
58 UI_method_set_opener(ui_method, ui_open);
59 UI_method_set_reader(ui_method, ui_read);
60 UI_method_set_writer(ui_method, ui_write);
61 UI_method_set_closer(ui_method, ui_close);
63 UI_set_default_method(ui_method);