DSL
openssl.h
1 //@AUTOHEADER@BEGIN@
2 /***********************************************************************\
3 | Drift Standard Libraries v1.01 |
4 | Copyright 2010-2023 Drift Solutions / Indy Sams |
5 | Docs and more information available at https://www.driftsolutions.dev |
6 | This file released under the 3-clause BSD license, |
7 | see included DSL.LICENSE.TXT file for details. |
8 \***********************************************************************/
9 //@AUTOHEADER@END@
10 
11 #ifndef __DRIFT_OPENSSL_H__
12 #define __DRIFT_OPENSSL_H__
13 
14 #include <drift/sockets3.h>
15 
16 #if defined(DSL_DLL) && defined(WIN32)
17  #if defined(DSL_OPENSSL_EXPORTS)
18  #define DSL_OPENSSL_API extern "C" __declspec(dllexport)
19  #define DSL_OPENSSL_API_CLASS __declspec(dllexport)
20  #else
21  #define DSL_OPENSSL_API extern "C" __declspec(dllimport)
22  #define DSL_OPENSSL_API_CLASS __declspec(dllimport)
23  #endif
24 #else
25  #define DSL_OPENSSL_API DSL_API_VIS
26  #define DSL_OPENSSL_API_CLASS DSL_API_VIS
27 #endif
28 
29 class DSL_OPENSSL_API_CLASS DSL_SOCKET_OPENSSL : public DSL_SOCKET {
30 public:
31  SSL * ssl = NULL;
32 };
33 
34 class DSL_OPENSSL_API_CLASS DSL_Sockets3_OpenSSL: public DSL_Sockets3_SSL {
35  protected:
36  virtual DSL_SOCKET * pAllocSocket();
37  virtual int pRecv(DSL_SOCKET * sock, char * buf, uint32 bufsize);
38  virtual int pPeek(DSL_SOCKET * sock, char * buf, uint32 bufsize);
39  virtual int pSend(DSL_SOCKET * sock, const char * buf, uint32 bufsize);
40  virtual int pSelect_Read(DSL_SOCKET * sock, timeval * timeo);
41  virtual void pCloseSSL(DSL_SOCKET * sock);
42  private:
43  SSL_CTX * ctx = NULL;
44  public:
46  virtual ~DSL_Sockets3_OpenSSL();
47 
48  virtual bool EnableSSL(const char * cert_fn, DS3_SSL_METHOD method);
49  virtual bool SwitchToSSL_Server(DSL_SOCKET * sock);
50  virtual bool SwitchToSSL_Client(DSL_SOCKET * sock);
51 
52  virtual X509 * GetSSL_Cert(DSL_SOCKET * sock);
53  virtual SSL_CTX * GetSSL_CTX();
54 };
55 
56 #endif // __DRIFT_OPENSSL_H__
DS3_SSL_METHOD
Definition: sockets3.h:67