summaryrefslogtreecommitdiff
path: root/src/pt-tls-client
diff options
context:
space:
mode:
Diffstat (limited to 'src/pt-tls-client')
-rw-r--r--src/pt-tls-client/Makefile.in5
-rw-r--r--src/pt-tls-client/pt-tls-client.c30
2 files changed, 25 insertions, 10 deletions
diff --git a/src/pt-tls-client/Makefile.in b/src/pt-tls-client/Makefile.in
index b2c9c9598..3a8ffb8fd 100644
--- a/src/pt-tls-client/Makefile.in
+++ b/src/pt-tls-client/Makefile.in
@@ -322,7 +322,6 @@ clearsilver_LIBS = @clearsilver_LIBS@
cmd_plugins = @cmd_plugins@
datadir = @datadir@
datarootdir = @datarootdir@
-dbusservicedir = @dbusservicedir@
dev_headers = @dev_headers@
docdir = @docdir@
dvidir = @dvidir@
@@ -356,8 +355,6 @@ libiptc_LIBS = @libiptc_LIBS@
linux_headers = @linux_headers@
localedir = @localedir@
localstatedir = @localstatedir@
-maemo_CFLAGS = @maemo_CFLAGS@
-maemo_LIBS = @maemo_LIBS@
manager_plugins = @manager_plugins@
mandir = @mandir@
medsrv_plugins = @medsrv_plugins@
@@ -411,6 +408,8 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+tss2_CFLAGS = @tss2_CFLAGS@
+tss2_LIBS = @tss2_LIBS@
urandom_device = @urandom_device@
xml_CFLAGS = @xml_CFLAGS@
xml_LIBS = @xml_LIBS@
diff --git a/src/pt-tls-client/pt-tls-client.c b/src/pt-tls-client/pt-tls-client.c
index b91997ddd..6f200c316 100644
--- a/src/pt-tls-client/pt-tls-client.c
+++ b/src/pt-tls-client/pt-tls-client.c
@@ -42,7 +42,7 @@ static void usage(FILE *out)
{
fprintf(out,
"Usage: pt-tls --connect <hostname|address> [--port <port>]\n"
- " [--cert <file>]+ [--key <file>]\n"
+ " [--cert <file>]+ [--key <file>] [--key-type rsa|ecdsa]\n"
" [--client <client-id>] [--secret <password>]\n"
" [--optionsfrom <filename>] [--quiet] [--debug <level>]\n");
}
@@ -121,11 +121,11 @@ static bool load_certificate(char *filename)
/**
* Load private key from file
*/
-static bool load_key(char *filename)
+static bool load_key(char *filename, key_type_t type)
{
private_key_t *key;
- key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
+ key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, type,
BUILD_FROM_FILE, filename, BUILD_END);
if (!key)
{
@@ -255,7 +255,8 @@ static void init()
int main(int argc, char *argv[])
{
- char *address = NULL, *identity = "%any", *secret = NULL;
+ char *address = NULL, *identity = "%any", *secret = NULL, *key_file = NULL;
+ key_type_t key_type = KEY_RSA;
int port = PT_TLS_PORT;
init();
@@ -270,6 +271,7 @@ int main(int argc, char *argv[])
{"port", required_argument, NULL, 'p' },
{"cert", required_argument, NULL, 'x' },
{"key", required_argument, NULL, 'k' },
+ {"key-type", required_argument, NULL, 't' },
{"mutual", no_argument, NULL, 'm' },
{"quiet", no_argument, NULL, 'q' },
{"debug", required_argument, NULL, 'd' },
@@ -290,9 +292,20 @@ int main(int argc, char *argv[])
}
continue;
case 'k': /* --key <file> */
- if (!load_key(optarg))
+ key_file = optarg;
+ continue;
+ case 't': /* --key-type <type> */
+ if (strcaseeq(optarg, "ecdsa"))
{
- return 1;
+ key_type = KEY_ECDSA;
+ }
+ else if (strcaseeq(optarg, "rsa"))
+ {
+ key_type = KEY_RSA;
+ }
+ else
+ {
+ key_type = KEY_ANY;
}
continue;
case 'c': /* --connect <hostname|address> */
@@ -339,12 +352,15 @@ int main(int argc, char *argv[])
usage(stderr);
return 1;
}
+ if (key_file && !load_key(key_file, key_type))
+ {
+ return 1;
+ }
if (secret)
{
creds->add_shared(creds, shared_key_create(SHARED_EAP,
chunk_clone(chunk_from_str(secret))),
identification_create_from_string(identity), NULL);
}
-
return client(address, port, identity);
}