Code

Call the SSL library initialization functions only once (not for every
authorHolger Weiss <hweiss@users.sourceforge.net>
Fri, 1 Jun 2007 22:57:31 +0000 (22:57 +0000)
committerHolger Weiss <hweiss@users.sourceforge.net>
Fri, 1 Jun 2007 22:57:31 +0000 (22:57 +0000)
SSL connection).

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1726 f882894a-f735-0410-b71e-b25c423dba1c

plugins/sslutils.c

index 84a1c8fc9c121f1248bd551b4f12f9ae54f0e71d..8d2e93c7977644cf18f6e76d5f92fb94cfbb9dbe 100644 (file)
 #ifdef HAVE_SSL
 static SSL_CTX *c=NULL;
 static SSL *s=NULL;
+static int initialized=0;
 
 int np_net_ssl_init (int sd){
-               SSL_METHOD *m=NULL;
-               /* Initialize SSL context */
-               SSLeay_add_ssl_algorithms ();
-               m = SSLv23_client_method ();
-               SSL_load_error_strings ();
-               OpenSSL_add_all_algorithms();
-               if ((c = SSL_CTX_new (m)) == NULL) {
+               if (!initialized) {
+                       /* Initialize SSL context */
+                       SSLeay_add_ssl_algorithms ();
+                       SSL_load_error_strings ();
+                       OpenSSL_add_all_algorithms ();
+                       initialized = 1;
+               }
+               if ((c = SSL_CTX_new (SSLv23_client_method ())) == NULL) {
                                printf ("%s\n", _("CRITICAL - Cannot create SSL context."));
                                return STATE_CRITICAL;
                }