diff options
Diffstat (limited to 'demos/bio')
-rw-r--r-- | demos/bio/Makefile | 38 | ||||
-rw-r--r-- | demos/bio/client-arg.c | 6 | ||||
-rw-r--r-- | demos/bio/client-conf.c | 7 | ||||
-rw-r--r-- | demos/bio/saccept.c | 10 | ||||
-rw-r--r-- | demos/bio/sconnect.c | 15 |
5 files changed, 47 insertions, 29 deletions
diff --git a/demos/bio/Makefile b/demos/bio/Makefile index 86f19d4df3af..5171e75e5981 100644 --- a/demos/bio/Makefile +++ b/demos/bio/Makefile @@ -1,22 +1,22 @@ -# Quick instruction: -# To build against an OpenSSL built in the source tree, do this: # -# make OPENSSL_INCS_LOCATION=-I../../include OPENSSL_LIBS_LOCATION=-L../.. -# -# To run the demos when linked with a shared library (default): +# To run the demos when linked with a shared library (default) ensure that +# libcrypto and libssl are on the library path. For example: # # LD_LIBRARY_PATH=../.. ./server-arg -# LD_LIBRARY_PATH=../.. ./server-cmod -# LD_LIBRARY_PATH=../.. ./server-conf -# LD_LIBRARY_PATH=../.. ./client-arg -# LD_LIBRARY_PATH=../.. ./client-conf -# LD_LIBRARY_PATH=../.. ./saccept -# LD_LIBRARY_PATH=../.. ./sconnect -CFLAGS = $(OPENSSL_INCS_LOCATION) -LDFLAGS = $(OPENSSL_LIBS_LOCATION) -lssl -lcrypto $(EX_LIBS) +TESTS = client-arg \ + client-conf \ + saccept \ + sconnect \ + server-arg \ + server-cmod \ + server-conf + +CFLAGS = -I../../include -g -Wall +LDFLAGS = -L../.. +LDLIBS = -lssl -lcrypto -all: client-arg client-conf saccept sconnect server-arg server-cmod server-conf +all: $(TESTS) client-arg: client-arg.o client-conf: client-conf.o @@ -26,8 +26,12 @@ server-arg: server-arg.o server-cmod: server-cmod.o server-conf: server-conf.o -client-arg client-conf saccept sconnect server-arg server-cmod server-conf: - $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) +$(TESTS): + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LDLIBS) clean: - $(RM) *.o client-arg client-conf saccept sconnect server-arg server-cmod server-conf + $(RM) $(TESTS) *.o + +test: all + @echo "\nBIO tests:" + @echo "skipped" diff --git a/demos/bio/client-arg.c b/demos/bio/client-arg.c index 202afa1ee8ec..c4abdf5cd351 100644 --- a/demos/bio/client-arg.c +++ b/demos/bio/client-arg.c @@ -1,5 +1,5 @@ /* - * Copyright 2013-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2013-2023 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -22,6 +22,7 @@ int main(int argc, char **argv) char **args = argv + 1; const char *connect_str = "localhost:4433"; int nargs = argc - 1; + int ret = EXIT_FAILURE; ctx = SSL_CTX_new(TLS_client_method()); cctx = SSL_CONF_CTX_new(); @@ -100,9 +101,10 @@ int main(int argc, char **argv) break; BIO_write(out, tmpbuf, len); } + ret = EXIT_SUCCESS; end: SSL_CONF_CTX_free(cctx); BIO_free_all(sbio); BIO_free(out); - return 0; + return ret; } diff --git a/demos/bio/client-conf.c b/demos/bio/client-conf.c index 916876bfab94..766f1b5299a5 100644 --- a/demos/bio/client-conf.c +++ b/demos/bio/client-conf.c @@ -1,5 +1,5 @@ /* - * Copyright 2013-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2013-2023 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -25,6 +25,7 @@ int main(int argc, char **argv) CONF_VALUE *cnf; const char *connect_str = "localhost:4433"; long errline = -1; + int ret = EXIT_FAILURE; conf = NCONF_new(NULL); @@ -108,10 +109,12 @@ int main(int argc, char **argv) break; BIO_write(out, tmpbuf, len); } + ret = EXIT_SUCCESS; + end: SSL_CONF_CTX_free(cctx); BIO_free_all(sbio); BIO_free(out); NCONF_free(conf); - return 0; + return ret; } diff --git a/demos/bio/saccept.c b/demos/bio/saccept.c index 6da22ea44091..604051cda966 100644 --- a/demos/bio/saccept.c +++ b/demos/bio/saccept.c @@ -1,5 +1,5 @@ /* - * Copyright 1998-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1998-2024 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -27,13 +27,16 @@ static volatile int done = 0; -void interrupt(int sig) +static void interrupt(int sig) { done = 1; } -void sigsetup(void) +static void sigsetup(void) { +#if defined(OPENSSL_SYS_WINDOWS) + signal(SIGINT, interrupt); +#else struct sigaction sa; /* @@ -43,6 +46,7 @@ void sigsetup(void) sa.sa_handler = interrupt; sigemptyset(&sa.sa_mask); sigaction(SIGINT, &sa, NULL); +#endif } int main(int argc, char *argv[]) diff --git a/demos/bio/sconnect.c b/demos/bio/sconnect.c index 18f7007ce708..b4ad3df14b37 100644 --- a/demos/bio/sconnect.c +++ b/demos/bio/sconnect.c @@ -1,5 +1,5 @@ /* - * Copyright 1998-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1998-2024 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -16,11 +16,16 @@ */ #include <stdio.h> #include <stdlib.h> -#include <unistd.h> #include <string.h> #include <errno.h> #include <openssl/err.h> #include <openssl/ssl.h> +#if !defined(OPENSSL_SYS_WINDOWS) +#include <unistd.h> +#else +#include <windows.h> +# define sleep(x) Sleep(x*1000) +#endif #define HOSTPORT "localhost:4433" #define CAFILE "root.pem" @@ -30,7 +35,6 @@ int main(int argc, char *argv[]) const char *hostport = HOSTPORT; const char *CAfile = CAFILE; const char *hostname; - char *cp; BIO *out = NULL; char buf[1024 * 10], *p; SSL_CTX *ssl_ctx = NULL; @@ -52,9 +56,10 @@ int main(int argc, char *argv[]) /* Enable trust chain verification */ SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, NULL); - SSL_CTX_load_verify_locations(ssl_ctx, CAfile, NULL); + if (!SSL_CTX_load_verify_locations(ssl_ctx, CAfile, NULL)) + goto err; - /* Lets make a SSL structure */ + /* Let's make an SSL structure */ ssl = SSL_new(ssl_ctx); SSL_set_connect_state(ssl); |