CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
PsySSL.h
Go to the documentation of this file.
1//#include <stdio.h>
2//#include <string.h>
3//#include <iostream>
4
20#ifndef __SSL_SERVER_H__
21#define __SSL_SERVER_H__
22
23#include "Utils.h"
24
25namespace cmlabs{
26
31int TestSSL(int port);
32
33#ifdef _USE_SSL_
34 #include <openssl/ssl.h>
35 #include <openssl/err.h>
36
42class PsySSLServer {
43public:
45 PsySSLServer();
47 ~PsySSLServer();
48
54 bool init(char *cFile, char *kFile);
55
56private:
57 SSL_CTX *ctx;
58 SSL *ssl;
59
60 void CreateCTX(void);
61 void LoadCerts(char *cFile, char *kFile);
62};
63
64
65using namespace std;
66
68typedef void *(*P_ARG)(void *);
69
76class SSLServer {
77 // Private data
78 private:
79 SSL_CTX *ctx;
80 int PORT;
81 fd_set fdset;
82 // FD for server
83 int master;
84 // Thread function
85 P_ARG pthr_f;
86
87 // Private Functions
88 private:
89 // Load algorithms and create context.
90 void CreateCTX(void);
91 // Load certification files.
92 void LoadCerts(const char *cFile, const char *kFile);
93 // Create and attach socket.
94 void BindPort(void);
95
96 public:
100 void SetPthread_F(P_ARG fp) { pthr_f = fp; }
101
107 SSLServer(const char *cFile, const char *kFile, int port);
108
117 void CheckClients(int wait_t = 0);
118};
119
120#endif
121
122}
123
124#endif // _USE_SSL_
Cross-platform utility toolbox for CMSDK: threading, synchronization, shared memory,...
int TestSSL(int port)
Standalone smoke test for the SSL server functionality.
Definition PsySSL.cpp:236