diff options
author | Holger Weiss <hweiss@users.sourceforge.net> | 2007-06-01 22:57:31 +0000 |
---|---|---|
committer | Holger Weiss <hweiss@users.sourceforge.net> | 2007-06-01 22:57:31 +0000 |
commit | f71de78952ff36860e1a4a423d3d3f03c4714488 (patch) | |
tree | 97127da30fe8da25d344bb8d556bca6bb9640dfb /plugins/sslutils.c | |
parent | f747b865aa23e31c94ef350ab601485fea1a1a7e (diff) | |
download | monitoring-plugins-f71de78952ff36860e1a4a423d3d3f03c4714488.tar.gz |
Call the SSL library initialization functions only once (not for every
SSL connection).
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1726 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/sslutils.c')
-rw-r--r-- | plugins/sslutils.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/plugins/sslutils.c b/plugins/sslutils.c index 84a1c8fc..8d2e93c7 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c | |||
@@ -38,15 +38,17 @@ | |||
38 | #ifdef HAVE_SSL | 38 | #ifdef HAVE_SSL |
39 | static SSL_CTX *c=NULL; | 39 | static SSL_CTX *c=NULL; |
40 | static SSL *s=NULL; | 40 | static SSL *s=NULL; |
41 | static int initialized=0; | ||
41 | 42 | ||
42 | int np_net_ssl_init (int sd){ | 43 | int np_net_ssl_init (int sd){ |
43 | SSL_METHOD *m=NULL; | 44 | if (!initialized) { |
44 | /* Initialize SSL context */ | 45 | /* Initialize SSL context */ |
45 | SSLeay_add_ssl_algorithms (); | 46 | SSLeay_add_ssl_algorithms (); |
46 | m = SSLv23_client_method (); | 47 | SSL_load_error_strings (); |
47 | SSL_load_error_strings (); | 48 | OpenSSL_add_all_algorithms (); |
48 | OpenSSL_add_all_algorithms(); | 49 | initialized = 1; |
49 | if ((c = SSL_CTX_new (m)) == NULL) { | 50 | } |
51 | if ((c = SSL_CTX_new (SSLv23_client_method ())) == NULL) { | ||
50 | printf ("%s\n", _("CRITICAL - Cannot create SSL context.")); | 52 | printf ("%s\n", _("CRITICAL - Cannot create SSL context.")); |
51 | return STATE_CRITICAL; | 53 | return STATE_CRITICAL; |
52 | } | 54 | } |