summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0c16d15)
raw | patch | inline | side by side (parent: 0c16d15)
author | Sebastian Harl <sh@tokkee.org> | |
Mon, 9 Feb 2015 17:43:39 +0000 (18:43 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Mon, 9 Feb 2015 17:43:39 +0000 (18:43 +0100) |
Use those functions in sysdb and sysdbd instead of calling the OpenSSL
functions directly.
functions directly.
src/include/utils/ssl.h | patch | blob | history | |
src/tools/sysdb/main.c | patch | blob | history | |
src/tools/sysdbd/main.c | patch | blob | history | |
src/utils/ssl.c | patch | blob | history |
index 5379bc9ebf7f15af9b93844b9c78e6fc3c045a38..f15d3fab362cdbf3bc63ccf2a0d0ab776fc78c3c 100644 (file)
--- a/src/include/utils/ssl.h
+++ b/src/include/utils/ssl.h
struct sdb_ssl_session;
typedef struct sdb_ssl_session sdb_ssl_session_t;
+/*
+ * sdb_ssl_init, sdb_ssl_shutdown:
+ * Global setup and shutdown of SSL/TLS. This is required before any other
+ * function can be used.
+ */
+void
+sdb_ssl_init(void);
+void
+sdb_ssl_shutdown(void);
+
/*
* sdb_ssl_client_create:
* Allocate and initialize a TLS/SSL client using the specified options. If no
diff --git a/src/tools/sysdb/main.c b/src/tools/sysdb/main.c
index e9e2202635d1d89dcb238a6e6c18dd7b295695cb..c58c735675106da0ebc33afd94680cc7478dfc89 100644 (file)
--- a/src/tools/sysdb/main.c
+++ b/src/tools/sysdb/main.c
#include "utils/llist.h"
#include "utils/strbuf.h"
#include "utils/os.h"
+#include "utils/ssl.h"
#include <errno.h>
# endif
#endif /* READLINEs */
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-
#ifndef DEFAULT_SOCKET
# define DEFAULT_SOCKET "unix:"LOCALSTATEDIR"/run/sysdbd.sock"
#endif
if (! input.user)
exit(1);
- SSL_load_error_strings();
- OpenSSL_add_ssl_algorithms();
+ sdb_ssl_init();
input.client = sdb_client_create(host);
if (! input.client) {
}
sdb_input_reset(&input);
-
- ERR_free_strings();
+ sdb_ssl_shutdown();
return 0;
} /* main */
index 25f6499feecc4817903a4ccf13105c43d81ad08c..179ec791ab97302fbac8fc422b3e0f3651678f85 100644 (file)
--- a/src/tools/sysdbd/main.c
+++ b/src/tools/sysdbd/main.c
#include "core/plugin.h"
#include "core/store.h"
#include "utils/error.h"
+#include "utils/ssl.h"
#include "frontend/connection.h"
#include "frontend/sock.h"
#include <pthread.h>
-#include <openssl/ssl.h>
-#include <openssl/err.h>
-
#ifndef CONFIGFILE
# define CONFIGFILE SYSCONFDIR"/sysdb/sysdbd.conf"
#endif
if (daemonize())
exit(1);
- SSL_load_error_strings();
- OpenSSL_add_ssl_algorithms();
-
+ sdb_ssl_init();
sdb_plugin_init_all();
plugin_main_loop.default_interval = SECS_TO_SDB_TIME(60);
SDB_VERSION_EXTRA" (pid %i)", (int)getpid());
sdb_plugin_shutdown_all();
sdb_plugin_unregister_all();
-
- ERR_free_strings();
+ sdb_ssl_shutdown();
return status;
} /* main */
diff --git a/src/utils/ssl.c b/src/utils/ssl.c
index 723df2115600d404c3bf127c4d985e0fcc537203..fe509d05c3dd461e5e0d79620070abdeb5d97444 100644 (file)
--- a/src/utils/ssl.c
+++ b/src/utils/ssl.c
* public API
*/
+void
+sdb_ssl_init(void)
+{
+ SSL_load_error_strings();
+ OpenSSL_add_ssl_algorithms();
+} /* sdb_ssl_init */
+
+void
+sdb_ssl_shutdown(void)
+{
+ ERR_free_strings();
+} /* sdb_ssl_shutdown */
+
sdb_ssl_client_t *
sdb_ssl_client_create(const sdb_ssl_options_t *opts)
{