xrootd
XrdTlsSocket.hh
Go to the documentation of this file.
1 #ifndef __XRD_TLS_SOCKET_HH__
2 #define __XRD_TLS_SOCKET_HH__
3 //------------------------------------------------------------------------------
4 // Copyright (c) 2011-2018 by European Organization for Nuclear Research (CERN)
5 // Author: Michal Simon <simonm@cern.ch>
6 //------------------------------------------------------------------------------
7 // XRootD is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // XRootD is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19 //------------------------------------------------------------------------------
20 
21 #include <string>
22 
23 #include "XrdTls/XrdTls.hh"
24 
25 //----------------------------------------------------------------------------
26 // Forward declarations
27 //----------------------------------------------------------------------------
28 
29 class XrdNetAddrInfo;
30 class XrdSysError;
31 class XrdTlsContext;
32 class XrdTlsPeerCerts;
33 struct XrdTlsSocketImpl;
34 
35 //----------------------------------------------------------------------------
37 //----------------------------------------------------------------------------
38 
40 {
41 public:
42 
43 enum RW_Mode
44 {
49 };
50 
51 enum HS_Mode
52 {
53  TLS_HS_BLOCK = true,
54  TLS_HS_NOBLK = false,
55 };
56 
57 //------------------------------------------------------------------------
73 //------------------------------------------------------------------------
74 
75  XrdTlsSocket( XrdTlsContext &ctx, int sfd, RW_Mode rwm,
76  HS_Mode hsm, bool isClient );
77 
78 //------------------------------------------------------------------------
81 //------------------------------------------------------------------------
82 
84 
85 //------------------------------------------------------------------------
87 //------------------------------------------------------------------------
88 
90 
91 //------------------------------------------------------------------------
97 //------------------------------------------------------------------------
98 
99  XrdTls::RC Accept(std::string *eMsg=0);
100 
101 //------------------------------------------------------------------------
111 //------------------------------------------------------------------------
112 
113  XrdTls::RC Connect(const char *thehost=0, std::string *eWhy=0);
114 
115 //------------------------------------------------------------------------
119 //------------------------------------------------------------------------
120 
122 
123 //------------------------------------------------------------------------
132 //------------------------------------------------------------------------
133 
134 XrdTlsPeerCerts *getCerts(bool ver=true);
135 
136 //------------------------------------------------------------------------
157 //------------------------------------------------------------------------
158 
159  const char *Init( XrdTlsContext &ctx, int sfd, RW_Mode rwm, HS_Mode hsm,
160  bool isClient, const char *tid="" );
161 
162 //------------------------------------------------------------------------
171 //------------------------------------------------------------------------
172 
173  XrdTls::RC Peek( char *buffer, size_t size, int &bytesPeek );
174 
175 //------------------------------------------------------------------------
185 //------------------------------------------------------------------------
186 
187  int Pending(bool any=true);
188 
189 //------------------------------------------------------------------------
191 //
198 //------------------------------------------------------------------------
199 
200  XrdTls::RC Read( char *buffer, size_t size, int &bytesRead );
201 
202 //------------------------------------------------------------------------
206 //------------------------------------------------------------------------
207 
208  void SetTraceID(const char *tid);
209 
210 //------------------------------------------------------------------------
217 //------------------------------------------------------------------------
218 
219  enum SDType {sdForce = 1, sdImmed = 2, sdWait = 3};
220 
222 
223 //------------------------------------------------------------------------
232 //------------------------------------------------------------------------
233 
234  XrdTls::RC Write( const char *buffer, size_t size, int &bytesOut );
235 
236 //------------------------------------------------------------------------
239 //------------------------------------------------------------------------
240 
242 
243 //------------------------------------------------------------------------
245 //------------------------------------------------------------------------
246 
247  const char *Version();
248 
249 private:
250 
251 void AcceptEMsg(std::string *eWhy, const char *reason);
252 int Diagnose(const char *what, int sslrc, int tcode);
253 std::string Err2Text(int sslerr);
254 bool Wait4OK(bool wantRead);
255 
256 XrdTlsSocketImpl *pImpl;
257 };
258 #endif // __XRD_TLS_IO_HH__
Definition: XrdNetAddrInfo.hh:54
Definition: XrdSysError.hh:90
Definition: XrdTlsContext.hh:37
Definition: XrdTlsPeerCerts.hh:35
Socket wrapper for TLS I/O.
Definition: XrdTlsSocket.hh:40
std::string Err2Text(int sslerr)
SDType
Definition: XrdTlsSocket.hh:219
@ sdImmed
Definition: XrdTlsSocket.hh:219
@ sdWait
Definition: XrdTlsSocket.hh:219
@ sdForce
Definition: XrdTlsSocket.hh:219
HS_Mode
Definition: XrdTlsSocket.hh:52
@ TLS_HS_BLOCK
Always block during handshake.
Definition: XrdTlsSocket.hh:53
@ TLS_HS_NOBLK
Do not block during handshake.
Definition: XrdTlsSocket.hh:54
int Diagnose(const char *what, int sslrc, int tcode)
XrdTls::RC Accept(std::string *eMsg=0)
void Shutdown(SDType=sdImmed)
~XrdTlsSocket()
Destructor.
XrdTlsSocketImpl * pImpl
Definition: XrdTlsSocket.hh:256
RW_Mode
Definition: XrdTlsSocket.hh:44
@ TLS_RNB_WBL
Non-blocking read blocking write.
Definition: XrdTlsSocket.hh:46
@ TLS_RBL_WNB
blocking read non-blocking write
Definition: XrdTlsSocket.hh:47
@ TLS_RBL_WBL
blocking read blocking write
Definition: XrdTlsSocket.hh:48
@ TLS_RNB_WNB
Non-blocking read non-blocking write.
Definition: XrdTlsSocket.hh:45
bool NeedHandShake()
XrdTlsSocket(XrdTlsContext &ctx, int sfd, RW_Mode rwm, HS_Mode hsm, bool isClient)
XrdTls::RC Write(const char *buffer, size_t size, int &bytesOut)
const char * Version()
XrdTls::RC Read(char *buffer, size_t size, int &bytesRead)
Read from the TLS connection. If necessary, a handshake will be done.
XrdTls::RC Connect(const char *thehost=0, std::string *eWhy=0)
XrdTlsPeerCerts * getCerts(bool ver=true)
void AcceptEMsg(std::string *eWhy, const char *reason)
void SetTraceID(const char *tid)
const char * Init(XrdTlsContext &ctx, int sfd, RW_Mode rwm, HS_Mode hsm, bool isClient, const char *tid="")
int Pending(bool any=true)
XrdTls::RC Peek(char *buffer, size_t size, int &bytesPeek)
bool Wait4OK(bool wantRead)
XrdTlsContext * Context()
RC
Definition: XrdTls.hh:40