XRootD
Loading...
Searching...
No Matches
XrdTlsTempCA Class Reference

#include <XrdTlsTempCA.hh>

+ Collaboration diagram for XrdTlsTempCA:

Classes

class  TempCAGuard
 

Public Member Functions

 XrdTlsTempCA (XrdSysError *log, std::string ca_dir)
 
 ~XrdTlsTempCA ()
 
bool atLeastOneValidCRLFound () const
 
std::string CAFilename () const
 
std::string CRLFilename () const
 
bool IsValid () const
 

Detailed Description

This class provides manages a "CA file" that is a concatenation of all the CAs in a given CA directory. This is useful in TLS contexts where, instead of loading all CAs for each connection, we only want to load a single file.

This will hand out the CA file directly, allowing external libraries (such as libcurl) do the loading of CAs directly.

Definition at line 43 of file XrdTlsTempCA.hh.

Constructor & Destructor Documentation

◆ XrdTlsTempCA()

XrdTlsTempCA::XrdTlsTempCA ( XrdSysError * log,
std::string ca_dir )

Definition at line 336 of file XrdTlsTempCA.cc.

337 : m_log(*err),
338 m_ca_dir(ca_dir)
339{
340 // Setup communication pipes; we write one byte to the child to tell it to shutdown;
341 // it'll write one byte back to acknowledge before our destructor exits.
342 int pipes[2];
343 if (-1 == XrdSysFD_Pipe(pipes)) {
344 m_log.Emsg("XrdTlsTempCA", "Failed to create communication pipes", strerror(errno));
345 return;
346 }
347 m_maintenance_pipe_r = pipes[0];
348 m_maintenance_pipe_w = pipes[1];
349 if (-1 == XrdSysFD_Pipe(pipes)) {
350 m_log.Emsg("XrdTlsTempCA", "Failed to create communication pipes", strerror(errno));
351 return;
352 }
353 m_maintenance_thread_pipe_r = pipes[0];
354 m_maintenance_thread_pipe_w = pipes[1];
355 if (!Maintenance()) {return;}
356
357 pthread_t tid;
358 auto rc = XrdSysThread::Run(&tid, XrdTlsTempCA::MaintenanceThread,
359 static_cast<void*>(this), 0, "CA/CRL refresh");
360 if (rc) {
361 m_log.Emsg("XrdTlsTempCA", "Failed to launch CA monitoring thread");
362 m_ca_file.reset();
363 m_crl_file.reset();
364 }
365}
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)

References XrdSysError::Emsg(), and XrdSysThread::Run().

+ Here is the call graph for this function:

◆ ~XrdTlsTempCA()

XrdTlsTempCA::~XrdTlsTempCA ( )

Definition at line 368 of file XrdTlsTempCA.cc.

369{
370 char indicator[1];
371 if (m_maintenance_pipe_w >= 0) {
372 indicator[0] = '1';
373 int rval;
374 do {rval = write(m_maintenance_pipe_w, indicator, 1);} while (rval != -1 || errno == EINTR);
375 if (m_maintenance_thread_pipe_r >= 0) {
376 do {rval = read(m_maintenance_thread_pipe_r, indicator, 1);} while (rval != -1 || errno == EINTR);
377 close(m_maintenance_thread_pipe_r);
378 close(m_maintenance_thread_pipe_w);
379 }
380 close(m_maintenance_pipe_r);
381 close(m_maintenance_pipe_w);
382 }
383}
#define close(a)
Definition XrdPosix.hh:43
#define write(a, b, c)
Definition XrdPosix.hh:110
#define read(a, b, c)
Definition XrdPosix.hh:77

References close, read, and write.

Member Function Documentation

◆ atLeastOneValidCRLFound()

bool XrdTlsTempCA::atLeastOneValidCRLFound ( ) const
inline

Returns true if a valid CRL file has been found during the Maintenance thread execution false otherwise

Definition at line 69 of file XrdTlsTempCA.hh.

69{ return m_atLeastOneCRLFound; }

◆ CAFilename()

std::string XrdTlsTempCA::CAFilename ( ) const
inline

Returns the current location of the CA temp file.

Definition at line 58 of file XrdTlsTempCA.hh.

58{auto file_ref = m_ca_file; return file_ref ? *file_ref : "";}

◆ CRLFilename()

std::string XrdTlsTempCA::CRLFilename ( ) const
inline

Returns the current location of the CA temp file.

Definition at line 63 of file XrdTlsTempCA.hh.

63{auto file_ref = m_crl_file; return file_ref ? *file_ref : "";}

◆ IsValid()

bool XrdTlsTempCA::IsValid ( ) const
inline

Returns true if object is valid.

Definition at line 53 of file XrdTlsTempCA.hh.

53{return m_ca_file.get() && m_crl_file.get();}

The documentation for this class was generated from the following files: