1 /*
2    BAREOS® - Backup Archiving REcovery Open Sourced
3 
4    Copyright (C) 2018-2018 Bareos GmbH & Co. KG
5 
6    This program is Free Software; you can redistribute it and/or
7    modify it under the terms of version three of the GNU Affero General Public
8    License as published by the Free Software Foundation and included
9    in the file LICENSE.
10 
11    This program is distributed in the hope that it will be useful, but
12    WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14    Affero General Public License for more details.
15 
16    You should have received a copy of the GNU Affero General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19    02110-1301, USA.
20 */
21 #ifndef BAREOS_LIB_TLS_OPENSSL_H_
22 #define BAREOS_LIB_TLS_OPENSSL_H_
23 
24 #include "lib/tls.h"
25 
26 #include "include/bareos.h"
27 #include <memory>
28 
29 class TlsOpenSslPrivate;
30 
31 class TlsOpenSsl : public Tls {
32  public:
33   TlsOpenSsl();
34   virtual ~TlsOpenSsl();
35   TlsOpenSsl(TlsOpenSsl& other) = delete;
36 
37   bool init() override;
38 
39   bool TlsPostconnectVerifyHost(JobControlRecord* jcr,
40                                 const char* host) override;
41   bool TlsPostconnectVerifyCn(
42       JobControlRecord* jcr,
43       const std::vector<std::string>& verify_list) override;
44 
45   bool TlsBsockAccept(BareosSocket* bsock) override;
46   int TlsBsockWriten(BareosSocket* bsock, char* ptr, int32_t nbytes) override;
47   int TlsBsockReadn(BareosSocket* bsock, char* ptr, int32_t nbytes) override;
48   bool TlsBsockConnect(BareosSocket* bsock) override;
49   void TlsBsockShutdown(BareosSocket* bsock) override;
50 
51   std::string TlsCipherGetName() const override;
52   void SetCipherList(const std::string& cipherlist) override;
53   void TlsLogConninfo(JobControlRecord* jcr,
54                       const char* host,
55                       int port,
56                       const char* who) const override;
57   void SetTlsPskClientContext(const PskCredentials& credentials) override;
58   void SetTlsPskServerContext(ConfigurationParser* config) override;
59 
60   void Setca_certfile_(const std::string& ca_certfile) override;
61   void SetCaCertdir(const std::string& ca_certdir) override;
62   void SetCrlfile(const std::string& crlfile_) override;
63   void SetCertfile(const std::string& certfile_) override;
64   void SetKeyfile(const std::string& keyfile_) override;
65   void SetPemCallback(CRYPTO_PEM_PASSWD_CB pem_callback) override;
66   void SetPemUserdata(void* pem_userdata) override;
67   void SetDhFile(const std::string& dhfile_) override;
68   void SetVerifyPeer(const bool& verify_peer) override;
69   void SetTcpFileDescriptor(const int& fd) override;
70 
71  private:
72   std::unique_ptr<TlsOpenSslPrivate> d_; /* private data */
73 };
74 #endif  // BAREOS_LIB_TLS_OPENSSL_H_
75