xrootd
Loading...
Searching...
No Matches
XrdTlsContext.hh
Go to the documentation of this file.
1#ifndef __XRD_TLSCONTEXT_HH__
2#define __XRD_TLSCONTEXT_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 <cstdint>
22#include <string>
23
24//----------------------------------------------------------------------------
25// Forward declarations
26//----------------------------------------------------------------------------
27
28class XrdSysLogger;
29struct XrdTlsContextImpl;
30struct XrdTlsSocket;
31
32/******************************************************************************/
33/* X r d T l s C o n t e x t */
34/******************************************************************************/
35
37{
38public:
39
40//------------------------------------------------------------------------
53//------------------------------------------------------------------------
54
55XrdTlsContext *Clone(bool full=true, bool startCRLRefresh = false);
56
57//------------------------------------------------------------------------
61//------------------------------------------------------------------------
62
63void *Context();
64
66static const int DEFAULT_CRL_REF_INT_SEC = 8 * 60 * 60;
67
68//------------------------------------------------------------------------
72//------------------------------------------------------------------------
73
75 {std::string cert;
76 std::string pkey;
77 std::string cadir;
78 std::string cafile;
79 uint64_t opts;
80 int crlRT;
81 int rsvd;
82
85 };
86
87const
89
90//------------------------------------------------------------------------
98//------------------------------------------------------------------------
99static
100const char *Init();
101
102//------------------------------------------------------------------------
106//------------------------------------------------------------------------
107
108bool isOK();
109
110//------------------------------------------------------------------------
114//------------------------------------------------------------------------
115
116void *Session();
117
118//------------------------------------------------------------------------
130//------------------------------------------------------------------------
131
132static const int scNone = 0x00000000;
133static const int scOff = 0x00010000;
134static const int scSrvr = 0x00020000;
135static const int scClnt = 0x00040000;
136static const int scKeep = 0x40000000;
137static const int scIdErr= 0x80000000;
138static const int scFMax = 0x00007fff;
140
141 int SessionCache(int opts=scNone, const char *id=0, int idlen=0);
142
143//------------------------------------------------------------------------
150//------------------------------------------------------------------------
151
152bool SetContextCiphers(const char *ciphers);
153
154//------------------------------------------------------------------------
158//------------------------------------------------------------------------
159static
160void SetDefaultCiphers(const char *ciphers);
161
162//------------------------------------------------------------------------
172//------------------------------------------------------------------------
173
174 bool SetCrlRefresh(int refsec=-1);
175
176//------------------------------------------------------------------------
180//------------------------------------------------------------------------
181
183
185
186//------------------------------------------------------------------------
227//------------------------------------------------------------------------
228
229static const uint64_t hsto = 0x00000000000000ff;
230static const uint64_t vdept = 0x000000000000ff00;
231static const int vdepS = 8;
232static const uint64_t logVF = 0x0000000800000000;
233static const uint64_t servr = 0x0000000400000000;
234static const uint64_t dnsok = 0x0000000200000000;
235static const uint64_t nopxy = 0x0000000100000000;
236static const uint64_t rfCRL = 0x0000004000000000;
237static const uint64_t crlON = 0x0000008000000000;
238static const uint64_t crlFC = 0x000000C000000000;
239static const uint64_t crlRF = 0x00000000ffff0000;
240static const int crlRS = 16;
241static const uint64_t artON = 0x0000002000000000;
242
243 XrdTlsContext(const char *cert=0, const char *key=0,
244 const char *cadir=0, const char *cafile=0,
245 uint64_t opts=0, std::string *eMsg=0);
246
247//------------------------------------------------------------------------
249//------------------------------------------------------------------------
250
252
253//------------------------------------------------------------------------
255//------------------------------------------------------------------------
256
257 XrdTlsContext( const XrdTlsContext &ctx ) = delete;
258 XrdTlsContext( XrdTlsContext &&ctx ) = delete;
259
260 XrdTlsContext& operator=( const XrdTlsContext &ctx ) = delete;
262
263private:
264 XrdTlsContextImpl *pImpl;
265};
266
267/******************************************************************************/
268/* O p t i o n M a n i p u l a t i o n M a c r o s */
269/******************************************************************************/
270
271//------------------------------------------------------------------------
276//------------------------------------------------------------------------
277
278#define TLS_SET_HSTO(cOpts,hstv) \
279 ((cOpts & ~XrdTlsContext::hsto) | (hstv & XrdTlsContext::hsto))
280
281//------------------------------------------------------------------------
288//------------------------------------------------------------------------
289
290#define TLS_SET_REFINT(cOpts,refi) ((cOpts & ~XrdTlsContext::crlRF) |\
291 (XrdTlsContext::crlRF & (refi <<XrdTlsContext::crlRS)))
292
293//------------------------------------------------------------------------
300//------------------------------------------------------------------------
301
302#define TLS_SET_VDEPTH(cOpts,vdv) ((cOpts & ~XrdTlsContext::vdept) |\
303 (XrdTlsContext::vdept & (vdv <<XrdTlsContext::vdepS)))
304
305#endif // __XRD_TLSCONTEXT_HH__
Definition XrdSysLogger.hh:53
Definition XrdTlsContext.hh:37
static const char * Init()
static const int scIdErr
Info: Id not set, is too long.
Definition XrdTlsContext.hh:137
XrdTlsContext & operator=(const XrdTlsContext &ctx)=delete
XrdTlsContext * Clone(bool full=true, bool startCRLRefresh=false)
~XrdTlsContext()
Destructor.
static void SetDefaultCiphers(const char *ciphers)
static const uint64_t hsto
Mask to isolate the hsto.
Definition XrdTlsContext.hh:229
static const uint64_t vdept
Mask to isolate vdept.
Definition XrdTlsContext.hh:230
static const int crlRS
Bits to shift vdept.
Definition XrdTlsContext.hh:240
int SessionCache(int opts=scNone, const char *id=0, int idlen=0)
XrdTlsContext(const char *cert=0, const char *key=0, const char *cadir=0, const char *cafile=0, uint64_t opts=0, std::string *eMsg=0)
static const int scClnt
Turn on cache client mode.
Definition XrdTlsContext.hh:135
static const int DEFAULT_CRL_REF_INT_SEC
Default CRL refresh interval in seconds.
Definition XrdTlsContext.hh:66
static const uint64_t servr
This is a server context.
Definition XrdTlsContext.hh:233
static const uint64_t rfCRL
Turn on the CRL refresh thread.
Definition XrdTlsContext.hh:236
static const int scKeep
Info: TLS-controlled flush disabled.
Definition XrdTlsContext.hh:136
static const uint64_t nopxy
Do not allow proxy certs.
Definition XrdTlsContext.hh:235
static const int scNone
Do not change any option settings.
Definition XrdTlsContext.hh:132
XrdTlsContext(const XrdTlsContext &ctx)=delete
Disallow any copies of this object.
static const uint64_t logVF
Log verify failures.
Definition XrdTlsContext.hh:232
static const uint64_t crlFC
Full crl chain checking.
Definition XrdTlsContext.hh:238
bool x509Verify()
static const uint64_t crlON
Enables crl checking.
Definition XrdTlsContext.hh:237
static const uint64_t artON
Auto retry Handshake.
Definition XrdTlsContext.hh:241
void * Session()
void * Context()
XrdTlsContext(XrdTlsContext &&ctx)=delete
static const int vdepS
Bits to shift vdept.
Definition XrdTlsContext.hh:231
static const int scOff
Turn off cache.
Definition XrdTlsContext.hh:133
XrdTlsContext & operator=(XrdTlsContext &&ctx)=delete
static const uint64_t dnsok
Trust DNS for host name.
Definition XrdTlsContext.hh:234
bool newHostCertificateDetected()
bool SetContextCiphers(const char *ciphers)
static const int scFMax
Definition XrdTlsContext.hh:138
XrdTlsContextImpl * pImpl
Definition XrdTlsContext.hh:264
bool SetCrlRefresh(int refsec=-1)
static const int scSrvr
Turn on cache server mode (default)
Definition XrdTlsContext.hh:134
static const uint64_t crlRF
Mask to isolate crl refresh in min.
Definition XrdTlsContext.hh:239
const CTX_Params * GetParams()
Socket wrapper for TLS I/O.
Definition XrdTlsSocket.hh:40
Definition XrdTlsContext.hh:75
std::string cafile
-> ca cert file.
Definition XrdTlsContext.hh:78
~CTX_Params()
Definition XrdTlsContext.hh:84
uint64_t opts
Options as passed to the constructor.
Definition XrdTlsContext.hh:79
std::string cadir
-> ca cert directory.
Definition XrdTlsContext.hh:77
int rsvd
Definition XrdTlsContext.hh:81
int crlRT
crl refresh interval time in seconds
Definition XrdTlsContext.hh:80
std::string pkey
-> private key path.
Definition XrdTlsContext.hh:76
std::string cert
-> certificate path.
Definition XrdTlsContext.hh:75
CTX_Params()
Definition XrdTlsContext.hh:83