/[monit]/monit/ssl.c
ViewVC logotype

Diff of /monit/ssl.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by chopp, Fri Oct 11 20:59:58 2002 UTC revision 1.6 by chopp, Wed Oct 23 14:01:26 2002 UTC
# Line 23  Line 23 
23  #include <config.h>  #include <config.h>
24  #include <stdio.h>  #include <stdio.h>
25  #include <memory.h>  #include <memory.h>
26  #include <errno.h>  
27    #ifdef HAVE_SYS_TYPES_H
28  #include <sys/types.h>  #include <sys/types.h>
29    #endif
30    
31    #ifdef HAVE_SYS_SOCKET_H
32  #include <sys/socket.h>  #include <sys/socket.h>
33    #endif
34    
35    #ifdef HAVE_NETINET_IN_H
36  #include <netinet/in.h>  #include <netinet/in.h>
37    #endif
38    
39    #ifdef HAVE_ARPA_INET_H
40  #include <arpa/inet.h>  #include <arpa/inet.h>
41    #endif
42    
43    #ifdef HAVE_NETDB_H
44  #include <netdb.h>  #include <netdb.h>
45    #endif
46    
47    #ifdef HAVE_PTHREAD_H
48  #include <pthread.h>  #include <pthread.h>
49    #endif
50    
51    #ifdef HAVE_UNISTD_H
52  #include <unistd.h>  #include <unistd.h>
53    #endif
54    
55    #ifdef HAVE_ERRNO_H
56  #include <errno.h>  #include <errno.h>
57    #endif
58    
59  #ifdef HAVE_STRING_H  #ifdef HAVE_STRING_H
60  #include <string.h>  #include <string.h>
# Line 355  int delete_ssl_socket(ssl_connection *ss Line 378  int delete_ssl_socket(ssl_connection *ss
378    if((ssl->ctx != NULL) && (! ssl->accepted)) {    if((ssl->ctx != NULL) && (! ssl->accepted)) {
379    
380      SSL_CTX_free(ssl->ctx);      SSL_CTX_free(ssl->ctx);
381        
382    }    }
383    
384    free(ssl);    free(ssl);
# Line 398  ssl_server_connection * init_ssl_server Line 421  ssl_server_connection * init_ssl_server
421    
422    }    }
423    
424    if (SSL_CTX_use_certificate_file(ssl_server->ctx, pemfilename, SSL_FILETYPE_PEM) <= 0) {    if (SSL_CTX_use_certificate_file(ssl_server->ctx, pemfilename,
425                                       SSL_FILETYPE_PEM) <= 0) {
426    
427      error("Cannot initilize SSL server certificate!\n");      error("Cannot initilize SSL server certificate!\n");
428      goto sslerror;      goto sslerror;
429    
430    }    }
431    
432    if (SSL_CTX_use_PrivateKey_file(ssl_server->ctx, pemfilename, SSL_FILETYPE_PEM) <= 0) {    if (SSL_CTX_use_PrivateKey_file(ssl_server->ctx, pemfilename,
433                                      SSL_FILETYPE_PEM) <= 0) {
434    
435      error("Cannot initilize SSL server private key!\n");      error("Cannot initilize SSL server private key!\n");
436      goto sslerror;      goto sslerror;
# Line 608  ssl_connection * insert_accepted_ssl_soc Line 633  ssl_connection * insert_accepted_ssl_soc
633    
634  #ifdef HAVE_OPENSSL  #ifdef HAVE_OPENSSL
635    
636    ssl_connection * ssl = new_ssl_connection(NULL);    ssl_connection * ssl = (ssl_connection *) NEW(ssl);
637    
638      ssl->method= NULL;
639      ssl->handler= NULL;
640      ssl->cert= NULL;
641      ssl->cipher= NULL;
642      ssl->socket= 0;
643      ssl->next = NULL;
644      ssl->accepted = FALSE;
645      ssl->cert_md5 = NULL;
646      ssl->cert_md5_len = 0;
647    
648    if(( ssl_server == NULL ) || (ssl == NULL)) {    if(( ssl_server == NULL ) || (ssl == NULL)) {
649    
# Line 697  int delete_accepted_ssl_socket (ssl_serv Line 732  int delete_accepted_ssl_socket (ssl_serv
732    
733  #ifdef HAVE_OPENSSL  #ifdef HAVE_OPENSSL
734    
735      int return_value= TRUE;
736    
737    if ((ssl == NULL) ||  (ssl_server == NULL)) {    if ((ssl == NULL) ||  (ssl_server == NULL)) {
738      return FALSE;      return FALSE;
739    }    }
# Line 715  int delete_accepted_ssl_socket (ssl_serv Line 752  int delete_accepted_ssl_socket (ssl_serv
752    
753    END_LOCK;      END_LOCK;  
754    
755    cleanup_ssl_socket(ssl);    if (! cleanup_ssl_socket(ssl)) {
   delete_ssl_socket(ssl);  
756    
757    return TRUE;      return_value= FALSE;
758    
759      }
760          
761      if (! delete_ssl_socket(ssl)) {
762    
763        return_value= FALSE;
764    
765      }
766    
767      return return_value;
768    
769  #else  #else
770    
# Line 802  ssl_connection * accept_ssl_socket(ssl_s Line 848  ssl_connection * accept_ssl_socket(ssl_s
848    int len= sizeof(struct sockaddr_in);    int len= sizeof(struct sockaddr_in);
849    struct sockaddr_in in;    struct sockaddr_in in;
850    
851    no_crypt_socket= accept(ssl_server->server_socket, (struct sockaddr*)&in, &len);    no_crypt_socket= accept(ssl_server->server_socket, (struct sockaddr*)&in,
852                              &len);
853    
854    if ( no_crypt_socket >= 0 ) {    if ( no_crypt_socket >= 0 ) {
855            
# Line 1052  ssl_connection * new_ssl_connection(char Line 1099  ssl_connection * new_ssl_connection(char
1099    
1100    if ( clientpemfilename!=NULL ) {    if ( clientpemfilename!=NULL ) {
1101    
1102      if (SSL_CTX_use_certificate_file(ssl->ctx, clientpemfilename, SSL_FILETYPE_PEM) <= 0) {      if (SSL_CTX_use_certificate_file(ssl->ctx, clientpemfilename,
1103                                         SSL_FILETYPE_PEM) <= 0) {
1104    
1105        error("Cannot initilize SSL server certificate!\n");        error("Cannot initilize SSL server certificate!\n");
1106        goto sslerror;        goto sslerror;
1107                
1108      }      }
1109    
1110      if (SSL_CTX_use_PrivateKey_file(ssl->ctx, clientpemfilename, SSL_FILETYPE_PEM) <= 0) {      if (SSL_CTX_use_PrivateKey_file(ssl->ctx, clientpemfilename,
1111                                        SSL_FILETYPE_PEM) <= 0) {
1112    
1113        error("Cannot initilize SSL server private key!\n");        error("Cannot initilize SSL server private key!\n");
1114        goto sslerror;        goto sslerror;
# Line 1299  static int verify_callback(int preverify Line 1348  static int verify_callback(int preverify
1348    }    }
1349    
1350   accept:   accept:
1351    log("HTTPD connection accepted to %s!\n", subject);    /* log("HTTPD connection accepted to %s!\n", subject); */
1352    return 1; /* Accept connection */    return 1; /* Accept connection */
1353    
1354   reject:   reject:

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26