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