DCL 4.0
Loading...
Searching...
No Matches
SSLSocket.h
Go to the documentation of this file.
1#ifndef __DCL_SSL_SOCKET_H__
2#define __DCL_SSL_SOCKET_H__ 20110923
3
4#ifndef __DCL_CONFIG_H__
5#include <dcl/Config.h>
6#endif
7
8#if __DCL_USE_OPENSSL
9 #include <openssl/ssl.h>
10#elif __DCL_USE_SCHANNEL
11 #define SECURITY_WIN32
12 #include <sspi.h>
13 #include <schnlsp.h>
14 #ifdef _MSC_VER
15 #pragma comment(lib, "secur32.lib")
16 #endif
17#endif
18
19#ifndef __DCL_SOCKET_H__
20#include <dcl/Socket.h>
21#endif
22
23__DCL_BEGIN_NAMESPACE
24
26{
28
29public:
30 SSLException(Exception* _cause);
31#if __DCL_USE_OPENSSL
33#elif __DCL_USE_SCHANNEL
34 SSLException(SECURITY_STATUS ss);
35#endif
36 virtual String toString() const;
37
38protected:
39 String __message;
40};
41
49class DCLCAPI SSLSocket : public Socket
50{
52
53public:
54
55 virtual size_t available() const
57#if 0
58
59 virtual size_t read(void* _buf, size_t _n)
61
62 virtual size_t write(const void* _buf, size_t _n)
73 void bind(const Addr& _my_addr,
74 int _type = SOCK_STREAM, int _protocol = 0, bool _reuse = true
76
77 void accept(SSLSocket& _r)
79
80 void connect(const Addr& _serv_addr)
82#endif
83
84public:
85 // API implements
86 SSLSocket()
88
89 SSLSocket(const String& _addr, uint16_t _port)
91
92 virtual ~SSLSocket();
93
94 virtual void close()
96
97#if 0
98 void create(int _domain = AF_INET, int _type = SOCK_STREAM, int _protocol = 0)
100
101 void setNonblock()
103
104 void bind(const struct sockaddr* _my_addr, socklen_t _addrlen)
106
107 void listen(unsigned _backlog = 5)
109
110 void accept(SSLSocket& r, struct sockaddr* _addr, socklen_t* _addrlen)
112#endif
113
114 virtual void connect(const sockaddr* _serv_addr, socklen_t _addrlen)
116
120 virtual size_t send(const void* _buf, size_t _n, int _flags = 0)
122
126 virtual size_t recv(void* _buf, size_t _n, int _flags = 0)
128
129 bool isPeerCertificateVerified() const;
130
131 String getPeerCertificateCommonName() const;
132
133protected:
134#if __DCL_USE_OPENSSL
135 SSL_CTX* __ctx;
136 SSL* __ssl;
137#elif __DCL_USE_SCHANNEL
138 CredHandle __cred;
139 CtxtHandle __ctxt;
140#endif
141
142 void construct()
144};
145
146__DCL_END_NAMESPACE
147
148#endif // __DCL_SSL_SOCKET_H__
#define DCLCAPI
Definition Config.h:100
#define __DCL_THROWS2(e1, e2)
Definition Config.h:168
#define __DCL_THROWS1(e)
Definition Config.h:167
#define DECLARE_CLASSINFO(class_name)
Definition Object.h:210
ByteString r
_r
Definition SQLField.cpp:260
virtual String toString() const
Definition Exception.cpp:40
Exception(Exception *_cause=NULL)
String __message
Definition SSLSocket.h:39
virtual size_t send(const void *_buf, size_t _n, int _flags=0) __DCL_THROWS1(IOException *)
virtual size_t recv(void *_buf, size_t _n, int _flags=0) __DCL_THROWS1(IOException *)
SSLSocket() __DCL_THROWS1(SSLException *)
virtual void close() __DCL_THROWS1(IOException *)
SSLSocket(const String &_addr, uint16_t _port) __DCL_THROWS2(IOException *
bool isPeerCertificateVerified() const
virtual void connect(const sockaddr *_serv_addr, socklen_t _addrlen) __DCL_THROWS1(IOException *)
void construct() __DCL_THROWS1(SSLException *)
String getPeerCertificateCommonName() const