DCL 3.7.4
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_OPENSSL
9 #include <openssl/ssl.h>
10#elif __DCL_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_OPENSSL
33#elif __DCL_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(
74 const Addr& _my_addr,
75 int _type = SOCK_STREAM, int _protocol = 0, bool _reuse = true
77
78 void accept(SSLSocket& _r)
80
81 void connect(const Addr& _serv_addr)
83#endif
84
85public:
86 // API implements
87 SSLSocket()
89
90 SSLSocket(const String& _addr, uint16_t _port)
92
93 virtual ~SSLSocket();
94
95 virtual void close()
97
98#if 0
99 void create(int _domain = AF_INET, int _type = SOCK_STREAM, int _protocol = 0)
101
102 void setNonblock()
104
105 void bind(const struct sockaddr* _my_addr, socklen_t _addrlen)
107
108 void listen(unsigned _backlog = 5)
110
111 void accept(SSLSocket& r, struct sockaddr* _addr, socklen_t* _addrlen)
113#endif
114
115 virtual void connect(const sockaddr* _serv_addr, socklen_t _addrlen)
117
121 virtual size_t send(const void* _buf, size_t _n, int _flags = 0)
123
127 virtual size_t recv(void* _buf, size_t _n, int _flags = 0)
129
130 bool isPeerCertificateVerified() const;
131
132 String getPeerCertificateCommonName() const;
133
134protected:
135#if __DCL_OPENSSL
136 SSL_CTX* __ctx;
137 SSL* __ssl;
138#elif __DCL_SCHANNEL
139 CredHandle __cred;
140 CtxtHandle __ctxt;
141#endif
142
143 void construct()
145};
146
147__DCL_END_NAMESPACE
148
149#endif // __DCL_SSL_SOCKET_H__
#define DCLCAPI
Definition Config.h:95
#define __DCL_THROWS2(e1, e2)
Definition Config.h:153
#define __DCL_THROWS1(e)
Definition Config.h:152
IOException *size_t r
Definition MediaInfo.cpp:82
#define DECLARE_CLASSINFO(class_name)
Definition Object.h:227
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