00001
00002 #include <errno.h>
00003 #include <unistd.h>
00004 #include <malloc.h>
00005 #include <string.h>
00006 #include <arpa/inet.h>
00007 #include <sys/socket.h>
00008 #include <sys/types.h>
00009 #include <netinet/in.h>
00010 #include <resolv.h>
00011 #include <openssl/ssl.h>
00012 #include <openssl/err.h>
00013 #include <openssl/evp.h>
00014 #include <gmp.h>
00015 #include <pthread.h>
00016 #include<iostream>
00017
00018 #include "ClientList.h"
00019 #include "Connection.h"
00020
00021 #ifndef FAIL
00022 #define FAIL 0
00023 #endif
00024 #ifndef SUCCESS
00025 #define SUCCESS 1
00026 #endif
00027
00028 using namespace std;
00029
00030 #define PORTNUMBER 5000
00031 #define LOGFILE "Log.txt"
00032
00037 class SSLServer {
00038 int port;
00039 int sd;
00040 enum {
00041 CLOSE,
00042 INITIALIZED,
00043 OPEN,
00044 CONNECT
00045 } status;
00046 char* CertFile;
00047 char* KeyFile;
00048 char passwd[100];
00049 SSL_CTX *ctx;
00050 SSL *ssl;
00051 pthread_t thread;
00052 FILE *logfd;
00054 ClientList *clist;
00055 ConnectionList *connectList;
00056 public:
00057 SSLServer(void);
00058 SSLServer(int port);
00059 ~SSLServer(void);
00060 void setport(int port);
00061 int Open(int port);
00062 int Open();
00063 int setpassword(const char *passwd);
00064 int LoadCertificates(char* CertFile, char* KeyFile);
00065 X509 *ShowCerts(SSL* ssl);
00066 int asymmetricEncrypt(unsigned char *message,size_t inlen,unsigned char *cipherMessage,size_t *outlen);
00067 void* Servlet();
00068 int Accept();
00069
00070
00071
00072
00073 };
00074