TCP Socket - C Language
|
00001 00015 #ifndef COMMSSL_H_ 00016 #define COMMSSL_H_ 00017 00018 #include "comm.h" 00019 00020 #include <openssl/rand.h> 00021 #include <openssl/ssl.h> 00022 #include <openssl/err.h> 00023 00025 #define RSA_SERVER_CERT "server.crt" 00026 00027 #define RSA_SERVER_KEY "server.key" 00028 00029 #define RSA_SERVER_CA_CERT "server_ca.crt" 00030 00031 #define RSA_SERVER_CA_PATH "sys$common:[syshlp.examples.ssl]" 00032 00034 #define RSA_CLIENT_CERT "client.crt" 00035 00036 #define RSA_CLIENT_KEY "client.key" 00037 00038 #define RSA_CLIENT_CA_CERT "client_ca.crt" 00039 00040 #define RSA_CLIENT_CA_PATH "sys$common:[syshlp.examples.ssl]" 00041 00042 #define ON 1 00043 #define OFF 0 00044 00045 /* ----= TIPI =---- */ 00046 00048 typedef struct { 00049 comm * srvSk; 00050 SSL_CTX *ctx; 00051 } srvSkSSL; 00052 00054 typedef struct { 00055 int socket; 00056 SSL_CTX *ctx; 00057 SSL *ssl; 00058 } cli_conn; 00059 00060 00061 /* ----= FUNZIONI =---- */ 00062 00076 srvSkSSL * newSSLServerChannel(const char *service); 00077 00083 cli_conn * acceptSSLConnection(srvSkSSL * server); 00084 00095 int receiveSSLMessage(cli_conn * client, message_t * msg); 00096 00104 int sendSSLMessage(cli_conn * client, message_t * msg); 00105 00112 int closeSSLServerSocket(srvSkSSL * server); 00113 00120 int closeSSLConnection(cli_conn * client); 00121 00129 cli_conn * retrySSLConnection(const char * hostname, const char * service); 00130 00132 void unloadSSL(); 00133 00134 #endif /* COMMSSL_H_ */