diff options
author | Sam Hartman <hartmans@painless-security.com> | 2013-09-30 08:16:09 -0400 |
---|---|---|
committer | Sam Hartman <hartmans@painless-security.com> | 2013-09-30 08:16:09 -0400 |
commit | 5c48c1f34ebc0662ac24d2a92fdf89c6447a5cf8 (patch) | |
tree | 335f62a057f92f5c6f7064daf37025c2a1552373 /lib/examples | |
parent | ec43e1ae18f8b3b129ffdae83e20101edd413ff3 (diff) | |
parent | 968744389f35996a1e7133dfdaa0ff9f70b50119 (diff) |
Merge branch 'moonshot' into debian
Conflicts:
lib/Makefile.am
lib/build-aux/config.guess
lib/build-aux/config.sub
lib/build-aux/depcomp
lib/build-aux/ltmain.sh
lib/build-aux/missing
lib/m4/libtool.m4
lib/m4/ltoptions.m4
lib/m4/ltversion.m4
lib/m4/lt~obsolete.m4
lib/radsec.c
lib/radsecproxy/tlscommon.c
lib/tls.c
Diffstat (limited to 'lib/examples')
-rw-r--r-- | lib/examples/Makefile.am | 4 | ||||
-rw-r--r-- | lib/examples/client-blocking.c | 35 | ||||
-rw-r--r-- | lib/examples/client-psk.conf | 18 | ||||
-rw-r--r-- | lib/examples/client.conf | 6 |
4 files changed, 47 insertions, 16 deletions
diff --git a/lib/examples/Makefile.am b/lib/examples/Makefile.am index 17b87a3..f300627 100644 --- a/lib/examples/Makefile.am +++ b/lib/examples/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = foreign -INCLUDES = -I$(top_srcdir)/include -AM_CFLAGS = -Wall -g +INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir) +AM_CFLAGS = -Wall -Werror -g noinst_PROGRAMS = client client_SOURCES = client-blocking.c diff --git a/lib/examples/client-blocking.c b/lib/examples/client-blocking.c index 2cfd617..cce00bf 100644 --- a/lib/examples/client-blocking.c +++ b/lib/examples/client-blocking.c @@ -1,13 +1,11 @@ -/* RADIUS client doing blocking i/o. */ +/* RADIUS/RadSec client using libradsec in blocking mode. */ #include <stdio.h> -#include <string.h> -#include <unistd.h> #include <stdlib.h> -#include <event2/event.h> +#include <assert.h> #include <radsec/radsec.h> -#include <radsec/radsec-impl.h> #include <radsec/request.h> +#include "err.h" #include "debug.h" /* For rs_dump_packet(). */ #define SECRET "sikrit" @@ -15,16 +13,22 @@ #define USER_PW "password" struct rs_error * -blocking_client (const char *av1, const char *av2, int use_request_object_flag) +blocking_client (const char *config_fn, const char *configuration, + int use_request_object_flag) { struct rs_context *h = NULL; struct rs_connection *conn = NULL; struct rs_request *request = NULL; struct rs_packet *req = NULL, *resp = NULL; struct rs_error *err = NULL; + int r; - if (rs_context_create (&h)) - return NULL; + r = rs_context_create (&h); + if (r) + { + assert(r == RSE_NOMEM); + assert (!"out of RAM -- unable to create libradsec context"); + } #if !defined (USE_CONFIG_FILE) { @@ -43,9 +47,9 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag) goto cleanup; } #else /* defined (USE_CONFIG_FILE) */ - if (rs_context_read_config (h, av1)) + if (rs_context_read_config (h, config_fn)) goto cleanup; - if (rs_conn_create (h, &conn, av2)) + if (rs_conn_create (h, &conn, configuration)) goto cleanup; #endif /* defined (USE_CONFIG_FILE) */ @@ -93,6 +97,13 @@ blocking_client (const char *av1, const char *av2, int use_request_object_flag) return err; } +void +usage (int argc, char *argv[]) +{ + fprintf (stderr, "usage: %s: [-r] config-file config-name\n", argv[0]); + exit (1); +} + int main (int argc, char *argv[]) { @@ -105,10 +116,12 @@ main (int argc, char *argv[]) argc--; argv++; } + if (argc < 3) + usage (argc, argv); err = blocking_client (argv[1], argv[2], use_request_object_flag); if (err) { - fprintf (stderr, "%s\n", rs_err_msg (err)); + fprintf (stderr, "error: %s: %d\n", rs_err_msg (err), rs_err_code (err, 0)); return rs_err_code (err, 1); } return 0; diff --git a/lib/examples/client-psk.conf b/lib/examples/client-psk.conf new file mode 100644 index 0000000..7b35e23 --- /dev/null +++ b/lib/examples/client-psk.conf @@ -0,0 +1,18 @@ +# We keep PSK configurations in a separate config file until +# --enable-tls-psk is on by default. This configuration is not valid +# without PSK support. + +realm blocking-tls-psk { + type = "TLS" + timeout = 1 + retries = 3 + #pskstr = "sikrit psk" + pskhexstr = "deadbeef4711" + pskid = "Client_identity" + pskex = "PSK" + server { + hostname = "srv1" + service = "4433" + secret = "sikrit" + } +} diff --git a/lib/examples/client.conf b/lib/examples/client.conf index 47528c8..b0b4536 100644 --- a/lib/examples/client.conf +++ b/lib/examples/client.conf @@ -14,10 +14,10 @@ realm blocking-tls { timeout = 1 retries = 3 cacertfile = "tests/demoCA/newcerts/01.pem" - certfile = "tests/demoCA/newcerts/02.pem" - certkeyfile = "tests/demoCA/private/c2key.pem" + certfile = "tests/demoCA/newcerts/03.pem" + certkeyfile = "tests/demoCA/private/cli1.key" server { - hostname = "localhost" + hostname = "srv1" service = "2083" secret = "sikrit" } |