XRootD
XrdTls.hh
Go to the documentation of this file.
1 #ifndef __XRDTLS_H__
2 #define __XRDTLS_H__
3 /******************************************************************************/
4 /* */
5 /* X r d T l s . h h */
6 /* */
7 /* (c) 2019 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* Produced by Andrew Hanushevsky for Stanford University under contract */
9 /* DE-AC02-76-SFO0515 with the Department of Energy */
10 /* */
11 /* This file is part of the XRootD software suite. */
12 /* */
13 /* XRootD is free software: you can redistribute it and/or modify it under */
14 /* the terms of the GNU Lesser General Public License as published by the */
15 /* Free Software Foundation, either version 3 of the License, or (at your */
16 /* option) any later version. */
17 /* */
18 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21 /* License for more details. */
22 /* */
23 /* You should have received a copy of the GNU Lesser General Public License */
24 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26 /* */
27 /* The copyright holder's institutional names and contributor's names may not */
28 /* be used to endorse or promote products derived from this software without */
29 /* specific prior written permission of the institution or contributor. */
30 /******************************************************************************/
31 
32 #include <string>
33 
34 class XrdSysLogger;
35 
36 class XrdTls
37 {
38 public:
39 
40 enum RC {TLS_AOK = 0,
53  };
54 
55 //------------------------------------------------------------------------
62 //------------------------------------------------------------------------
63 
64 static void Emsg(const char *tid, const char *msg=0, bool flush=true);
65 
66 //------------------------------------------------------------------------
74 //------------------------------------------------------------------------
75 
76 static std::string RC2Text(XrdTls::RC rc, bool dbg=false);
77 
78 //------------------------------------------------------------------------
85 //------------------------------------------------------------------------
86 
87 typedef void (*msgCB_t)(const char *tid, const char *msg, bool sslmsg);
88 
89 static void SetMsgCB(msgCB_t cbP);
90 
91 //------------------------------------------------------------------------
97 //------------------------------------------------------------------------
98 
99 static const int dbgOFF = 0;
100 static const int dbgCTX = 1;
101 static const int dbgSOK = 2;
102 static const int dbgSIO = 4;
103 static const int dbgALL = 7;
104 static const int dbgOUT = 8;
105 
106 static void SetDebug(int opts, XrdSysLogger *logP=0);
107 
108 static void SetDebug(int opts, msgCB_t logP);
109 
110 //------------------------------------------------------------------------
116 //------------------------------------------------------------------------
117 
118 static RC ssl2RC(int sslrc);
119 
120 //------------------------------------------------------------------------
130 //------------------------------------------------------------------------
131 
132 static const char *ssl2Text(int sslrc, const char *dflt="unknown_error");
133 
134 //------------------------------------------------------------------------
136 //------------------------------------------------------------------------
137 
138 static void ClearErrorQueue();
139 };
140 #endif
struct myOpts opts
Definition: XrdTls.hh:37
void(* msgCB_t)(const char *tid, const char *msg, bool sslmsg)
Definition: XrdTls.hh:87
static void SetMsgCB(msgCB_t cbP)
Definition: XrdTls.cc:196
static std::string RC2Text(XrdTls::RC rc, bool dbg=false)
Definition: XrdTls.cc:127
static RC ssl2RC(int sslrc)
Definition: XrdTls.cc:205
static const int dbgSIO
Turn debugging in for socket I/O.
Definition: XrdTls.hh:102
static const int dbgSOK
Turn debugging in for socket operations.
Definition: XrdTls.hh:101
static const int dbgOUT
Force msgs to stderr for easier client debug.
Definition: XrdTls.hh:104
static void Emsg(const char *tid, const char *msg=0, bool flush=true)
Definition: XrdTls.cc:104
static void ClearErrorQueue()
Clear the SSL error queue for the calling thread.
Definition: XrdTls.cc:265
static const int dbgALL
Turn debugging for everything.
Definition: XrdTls.hh:103
static const int dbgOFF
Turn debugging off (initial deault)
Definition: XrdTls.hh:99
static const char * ssl2Text(int sslrc, const char *dflt="unknown_error")
Definition: XrdTls.cc:235
@ TLS_AOK
All went well, will always be zero.
Definition: XrdTls.hh:40
@ TLS_WantWrite
Reissue call when writes do not block.
Definition: XrdTls.hh:52
@ TLS_HNV_Error
A hostname validation error occuured.
Definition: XrdTls.hh:44
@ TLS_CON_Closed
TLS connection has been closed.
Definition: XrdTls.hh:41
@ TLS_WantRead
Reissue call when reads do not block.
Definition: XrdTls.hh:51
@ TLS_VER_Error
Certificate verification failed.
Definition: XrdTls.hh:48
@ TLS_CRT_Missing
The x509 certificate missing.
Definition: XrdTls.hh:42
@ TLS_WantAccept
Reissue call when Accept() completes.
Definition: XrdTls.hh:49
@ TLS_UNK_Error
An unknown error occurred.
Definition: XrdTls.hh:47
@ TLS_SYS_Error
A system call error occurred.
Definition: XrdTls.hh:46
@ TLS_WantConnect
Reissue call when Connect() completes.
Definition: XrdTls.hh:50
@ TLS_SSL_Error
An SSL error occurred.
Definition: XrdTls.hh:45
@ TLS_CTX_Missing
The TLS context is missing.
Definition: XrdTls.hh:43
static const int dbgCTX
Turn debugging in for context operations.
Definition: XrdTls.hh:100
static void SetDebug(int opts, XrdSysLogger *logP=0)
Definition: XrdTls.cc:177