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> |
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); |
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; |
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 |
|
|
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 |
} |
} |
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 |
|
|
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 |
|
|
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; |
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: |