forked from love2d/lua-https
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenSSLConnection.h
More file actions
62 lines (48 loc) · 1.62 KB
/
OpenSSLConnection.h
File metadata and controls
62 lines (48 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include "../common/config.h"
#ifdef HTTPS_BACKEND_OPENSSL
#include <openssl/ssl.h>
#include "../common/Connection.h"
#include "../common/PlaintextConnection.h"
class OpenSSLConnection : public Connection
{
public:
OpenSSLConnection();
virtual bool connect(const std::string &hostname, uint16_t port) override;
virtual size_t read(char *buffer, size_t size) override;
virtual size_t write(const char *buffer, size_t size) override;
virtual void close() override;
virtual ~OpenSSLConnection();
static bool valid();
private:
PlaintextConnection socket;
SSL_CTX *context;
SSL *conn;
struct SSLFuncs
{
SSLFuncs();
bool valid;
int (*library_init)();
int (*init_ssl)(uint64_t opts, const void *settings);
SSL_CTX *(*CTX_new)(const SSL_METHOD *method);
long (*CTX_ctrl)(SSL_CTX *ctx, int cmd, long larg, void *parg);
long (*CTX_set_options)(SSL_CTX *ctx, long options);
void (*CTX_set_verify)(SSL_CTX *ctx, int mode, void *verify_callback);
int (*CTX_set_default_verify_paths)(SSL_CTX *ctx);
void (*CTX_free)(SSL_CTX *ctx);
SSL *(*SSL_new)(SSL_CTX *ctx);
void (*SSL_free)(SSL *ctx);
int (*set_fd)(SSL *ssl, int fd);
int (*connect)(SSL *ssl);
int (*read)(SSL *ssl, void *buf, int num);
int (*write)(SSL *ssl, const void *buf, int num);
int (*shutdown)(SSL *ssl);
long (*get_verify_result)(const SSL *ssl);
X509 *(*get_peer_certificate)(const SSL *ssl);
const SSL_METHOD *(*SSLv23_method)();
int (*check_host)(X509 *cert, const char *name, size_t namelen, unsigned int flags, char **peername);
void (*X509_free)(X509* cert);
};
static SSLFuncs ssl;
};
#endif // HTTPS_BACKEND_OPENSSL