34 #ifndef _QORE_SSLSOCKETHELPER_H 36 #define _QORE_SSLSOCKETHELPER_H 38 #ifdef NEED_SSL_CTX_NEW_CONST 39 #define SSL_METHOD_CONST const 41 #define SSL_METHOD_CONST 44 hashdecl qore_socket_private;
52 static inline const char* get_action_method(SslAction action) {
54 case READ:
return "SSL_read";
55 case WRITE:
return "SSL_write";
56 case PEEK:
return "SSL_peek";
62 class SSLSocketHelper {
64 qore_socket_private& qs;
65 SSL_METHOD_CONST SSL_METHOD* meth =
nullptr;
66 SSL_CTX* ctx =
nullptr;
70 DLLLOCAL
int setIntern(
const char* meth,
int sd, X509* cert, EVP_PKEY* pk,
ExceptionSink* xsink);
73 DLLLOCAL
int doSSLUpgradeNonBlockingIO(
int rc,
const char* mname,
int timeout_ms,
const char* ssl_func,
ExceptionSink* xsink);
75 DLLLOCAL ~SSLSocketHelper();
78 DLLLOCAL
bool sslError(
ExceptionSink* xsink,
const char* meth,
const char* msg,
bool always_error =
true);
81 DLLLOCAL SSLSocketHelper(qore_socket_private& qs) : qs(qs) {
85 DLLLOCAL
bool deref() {
99 DLLLOCAL
int doSSLRW(
ExceptionSink* xsink,
const char* mname,
void* buf,
int num,
int timeout_ms, SslAction action,
bool do_timeout =
true);
101 DLLLOCAL
int setClient(
const char* mname,
const char* sni_target_host,
int sd, X509* cert, EVP_PKEY* pk,
ExceptionSink* xsink);
102 DLLLOCAL
int setServer(
const char* mname,
int sd, X509* cert, EVP_PKEY* pk,
ExceptionSink* xsink);
104 DLLLOCAL
int connect(
const char* mname,
int timeout_ms,
ExceptionSink* xsink);
106 DLLLOCAL
int accept(
const char* mname,
int timeout_ms,
ExceptionSink* xsink);
108 DLLLOCAL
int shutdown();
112 DLLLOCAL
int read(
const char* mname,
char* buf,
int size,
int timeout_ms,
ExceptionSink* xsink);
114 DLLLOCAL
int write(
const char* mname,
const void* buf,
int size,
int timeout_ms,
ExceptionSink* xsink);
115 DLLLOCAL
const char* getCipherName()
const;
116 DLLLOCAL
const char* getCipherVersion()
const;
117 DLLLOCAL X509* getPeerCertificate()
const;
118 DLLLOCAL
long verifyPeerCertificate()
const;
120 DLLLOCAL
void setVerifyMode(
int mode,
bool accept_all_certs,
const std::string& target);
122 DLLLOCAL
bool captureRemoteCert()
const;
123 DLLLOCAL
void clearRemoteCertContext()
const;
126 class SSLSocketReferenceHelper {
128 DLLLOCAL SSLSocketReferenceHelper(SSLSocketHelper* s,
bool set_thread_context =
false);
130 DLLLOCAL ~SSLSocketReferenceHelper();
134 bool context_saved =
false;
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:46