xrootd
Loading...
Searching...
No Matches
XrdTlsTempCA.hh
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d T l s T e m p C A . h h */
4/* */
5/* (c) 2021 by the Board of Trustees of the Leland Stanford, Jr., University */
6/* Produced by Brian Bockelman */
7/* */
8/* This file is part of the XRootD software suite. */
9/* */
10/* XRootD is free software: you can redistribute it and/or modify it under */
11/* the terms of the GNU Lesser General Public License as published by the */
12/* Free Software Foundation, either version 3 of the License, or (at your */
13/* option) any later version. */
14/* */
15/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
16/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
17/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
18/* License for more details. */
19/* */
20/* You should have received a copy of the GNU Lesser General Public License */
21/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
22/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
23/* */
24/* The copyright holder's institutional names and contributor's names may not */
25/* be used to endorse or promote products derived from this software without */
26/* specific prior written permission of the institution or contributor. */
27/******************************************************************************/
28
29#include <string>
30#include <memory>
31
32// Forward dec'ls.
33class XrdSysError;
34
44public:
45 class TempCAGuard;
46
47 XrdTlsTempCA(XrdSysError *log, std::string ca_dir);
49
53 bool IsValid() const {return m_ca_file.get() && m_crl_file.get();}
54
58 std::string CAFilename() const {auto file_ref = m_ca_file; return file_ref ? *file_ref : "";}
59
63 std::string CRLFilename() const {auto file_ref = m_crl_file; return file_ref ? *file_ref : "";}
64
70
75 public:
76 static std::unique_ptr<TempCAGuard> create(XrdSysError &, const std::string &ca_tmp_dir);
77
78 int getCAFD() const {return m_ca_fd;}
79 std::string getCAFilename() const {return m_ca_fname;}
80
81 int getCRLFD() const {return m_crl_fd;}
82 std::string getCRLFilename() const {return m_crl_fname;}
83
87 bool commit();
88
89 TempCAGuard(const TempCAGuard &) = delete;
90
92
93 private:
94 TempCAGuard(int ca_fd, int crl_fd, const std::string &ca_tmp_dir, const std::string &ca_fname, const std::string &crl_fname);
95
96 int m_ca_fd{-1};
97 int m_crl_fd{-1};
98 std::string m_ca_tmp_dir;
99 std::string m_ca_fname;
100 std::string m_crl_fname;
101 };
102
103
104private:
112
116 static void *MaintenanceThread(void *myself_raw);
117
127 const std::string m_ca_dir;
128 std::shared_ptr<std::string> m_ca_file;
129 std::shared_ptr<std::string> m_crl_file;
131
132 // After success, how long to wait until the next CA reload.
133 static constexpr unsigned m_update_interval = 900;
134 // After failure, how long to wait until the next CA reload.
135 static constexpr unsigned m_update_interval_failure = 10;
136};
Definition XrdSysError.hh:90
Definition XrdTlsTempCA.hh:74
int m_crl_fd
Definition XrdTlsTempCA.hh:97
std::string m_ca_fname
Definition XrdTlsTempCA.hh:99
static std::unique_ptr< TempCAGuard > create(XrdSysError &, const std::string &ca_tmp_dir)
std::string getCRLFilename() const
Definition XrdTlsTempCA.hh:82
std::string m_ca_tmp_dir
Definition XrdTlsTempCA.hh:98
TempCAGuard(int ca_fd, int crl_fd, const std::string &ca_tmp_dir, const std::string &ca_fname, const std::string &crl_fname)
std::string m_crl_fname
Definition XrdTlsTempCA.hh:100
std::string getCAFilename() const
Definition XrdTlsTempCA.hh:79
TempCAGuard(const TempCAGuard &)=delete
int m_ca_fd
Definition XrdTlsTempCA.hh:96
int getCAFD() const
Definition XrdTlsTempCA.hh:78
int getCRLFD() const
Definition XrdTlsTempCA.hh:81
Definition XrdTlsTempCA.hh:43
bool atLeastOneValidCRLFound() const
Definition XrdTlsTempCA.hh:69
std::shared_ptr< std::string > m_crl_file
Definition XrdTlsTempCA.hh:129
std::shared_ptr< std::string > m_ca_file
Definition XrdTlsTempCA.hh:128
int m_maintenance_pipe_r
Definition XrdTlsTempCA.hh:122
static constexpr unsigned m_update_interval_failure
Definition XrdTlsTempCA.hh:135
XrdTlsTempCA(XrdSysError *log, std::string ca_dir)
XrdSysError & m_log
Definition XrdTlsTempCA.hh:126
bool m_atLeastOneCRLFound
Definition XrdTlsTempCA.hh:130
static void * MaintenanceThread(void *myself_raw)
bool IsValid() const
Definition XrdTlsTempCA.hh:53
int m_maintenance_thread_pipe_r
Definition XrdTlsTempCA.hh:124
bool Maintenance()
std::string CAFilename() const
Definition XrdTlsTempCA.hh:58
const std::string m_ca_dir
Definition XrdTlsTempCA.hh:127
int m_maintenance_thread_pipe_w
Definition XrdTlsTempCA.hh:125
int m_maintenance_pipe_w
Definition XrdTlsTempCA.hh:123
static constexpr unsigned m_update_interval
Definition XrdTlsTempCA.hh:133
std::string CRLFilename() const
Definition XrdTlsTempCA.hh:63