]> git.sur5r.net Git - bacula/docs/blob - docs/manuals/en/main/tls.tex
Tweak update copyrights
[bacula/docs] / docs / manuals / en / main / tls.tex
1
2 \chapter{Bacula TLS -- Communications Encryption}
3 \label{CommEncryption}
4 \index[general]{TLS -- Communications Encryption}
5 \index[general]{Communications Encryption}
6 \index[general]{Encryption!Communications}
7 \index[general]{Encryption!Transport}
8 \index[general]{Transport Encryption}
9 \index[general]{TLS}
10
11 Bacula TLS (Transport Layer Security) is built-in network
12 encryption code to provide secure network transport similar to
13 that offered by {\bf stunnel} or {\bf ssh}.  The data written to  
14 Volumes by the Storage daemon is not encrypted by this code.
15 For data encryption, please see the \ilink{Data Encryption Chapter}{DataEncryption} of this manual.
16
17 The Bacula encryption implementations were written by Landon Fuller.
18
19 Supported features of this code include: 
20 \begin{itemize} 
21 \item Client/Server TLS Requirement Negotiation 
22 \item TLSv1 Connections with Server and Client Certificate
23 Validation 
24 \item Forward Secrecy Support via Diffie-Hellman Ephemeral Keying 
25 \end{itemize}
26
27 This document will refer to both "server" and "client" contexts.  These
28 terms refer to the accepting and initiating peer, respectively.
29
30 Diffie-Hellman anonymous ciphers are not supported by this code.  The
31 use of DH anonymous ciphers increases the code complexity and places
32 explicit trust upon the two-way CRAM-MD5 implementation.  CRAM-MD5 is
33 subject to known plaintext attacks, and it should be considered
34 considerably less secure than PKI certificate-based authentication.
35
36 Appropriate autoconf macros have been added to detect and use OpenSSL  
37 if enabled on the {\bf ./configure} line with {\bf \verb?--?with-openssl}
38
39 \section{TLS Configuration Directives}
40 Additional configuration directives have been added to all the daemons
41 (Director, File daemon, and Storage daemon) as well as the various
42 different Console programs.
43 These new directives are defined as follows:
44
45 \begin{description}
46 \item [TLS Enable = \lt{}yes|no\gt{}]
47 Enable TLS support.  If TLS is not enabled, none of the other TLS directives
48 have any effect. In other words, even if you set {\bf TLS Require = yes} 
49 you need to have TLS enabled or TLS will not be used.
50
51 \item [TLS Require = \lt{}yes|no\gt{}]
52 Require TLS connections.  This directive is ignored unless {\bf TLS Enable}
53 is set to {\bf yes}.  If TLS is not required, and TLS is enabled, then
54 Bacula will connect with other daemons either with or without TLS depending
55 on what the other daemon requests.  If TLS is enabled and TLS is required,
56 then Bacula will refuse any connection that does not use TLS.
57
58 \item [TLS Certificate = \lt{}Filename\gt{}]
59 The full path and filename of a PEM encoded TLS certificate.  It can be
60 used as either a client or server certificate.  PEM stands for Privacy
61 Enhanced Mail, but in this context refers to how the certificates are
62 encoded.  It is used because PEM files are base64 encoded and hence ASCII
63 text based rather than binary.  They may also contain encrypted
64 information.
65
66 \item [TLS Key = \lt{}Filename\gt{}]
67 The full path and filename of a PEM encoded TLS private key.  It must
68 correspond to the TLS certificate.
69
70 \item [TLS Verify Peer = \lt{}yes|no\gt{}]
71 Verify peer certificate.  Instructs server to request and verify the
72 client's x509 certificate.  Any client certificate signed by a known-CA
73 will be accepted unless the TLS Allowed CN configuration directive is used,
74 in which case the client certificate must correspond to the Allowed
75 Common Name specified. This directive is valid only for a server
76 and not in a client context.
77
78 \item [TLS Allowed CN = \lt{}string list\gt{}]
79 Common name attribute of allowed peer certificates.  If this directive is
80 specified, all server certificates will be verified against this list. This
81 can be used to ensure that only the CA-approved Director may connect.
82 This directive may be specified more than once.
83
84 \item [TLS CA Certificate File = \lt{}Filename\gt{}]
85 The full path and filename specifying a
86 PEM encoded TLS CA certificate(s).  Multiple certificates are
87 permitted in the file.  One of \emph{TLS CA Certificate File} or \emph{TLS
88 CA Certificate Dir} are required in a server context if \emph{TLS
89 Verify Peer} (see above) is also specified, and are always required in a client
90 context.
91
92 \item [TLS CA Certificate Dir = \lt{}Directory\gt{}]
93 Full path to TLS CA certificate directory.  In the current implementation,
94 certificates must be stored PEM encoded with OpenSSL-compatible hashes,
95 which is the subject name's hash and an extension of {\bf .0}.
96 One of \emph{TLS CA Certificate File} or \emph{TLS CA Certificate Dir} are
97 required in a server context if \emph{TLS Verify Peer} is also specified,
98 and are always required in a client context.
99
100 \item [TLS DH File = \lt{}Directory\gt{}]
101 Path to PEM encoded Diffie-Hellman parameter file.  If this directive is
102 specified, DH key exchange will be used for the ephemeral keying, allowing
103 for forward secrecy of communications.  DH key exchange adds an additional
104 level of security because the key used for encryption/decryption by the
105 server and the client is computed on each end and thus is never passed over
106 the network if Diffie-Hellman key exchange is used.  Even if DH key
107 exchange is not used, the encryption/decryption key is always passed
108 encrypted.  This directive is only valid within a server context.
109
110 To generate the parameter file, you
111 may use openssl:
112
113 \begin{verbatim} 
114    openssl dhparam -out dh1024.pem -5 1024 
115 \end{verbatim}
116
117 \end{description}
118
119 \section{Creating a Self-signed Certificate}
120 \index[general]{Creating a Self-signed Certificate }
121 \index[general]{Certificate!Creating a Self-signed }
122
123 You may create a self-signed certificate for use with the Bacula TLS that
124 will permit you to make it function, but will not allow certificate
125 validation.  The .pem file containing both the certificate and the key
126 valid for ten years can be made with the following:
127
128 \footnotesize
129 \begin{verbatim}
130    openssl req -new -x509 -nodes -out bacula.pem -keyout bacula.pem -days 3650
131 \end{verbatim}
132 \normalsize
133
134 The above script will ask you a number of questions. You may simply answer
135 each of them by entering a return, or if you wish you may enter your own data.
136
137 Note, however, that self-signed certificates will only work for the
138 outgoing end of connections.  For example, in the case of the Director
139 making a connection to a File Daemon, the File Daemon may be configured to
140 allow self-signed certificates, but the certificate used by the
141 Director must be signed by a certificate that is explicitly trusted on the
142 File Daemon end.
143
144 This is necessary to prevent ``man in the middle'' attacks from tools such
145 as \elink{ettercap}{http://ettercap.sourceforge.net/}.  Essentially, if the
146 Director does not verify that it is talking to a trusted remote endpoint,
147 it can be tricked into talking to a malicious 3rd party who is relaying and
148 capturing all traffic by presenting its own certificates to the Director
149 and File Daemons.  The only way to prevent this is by using trusted
150 certificates, so that the man in the middle is incapable of spoofing the
151 connection using his own.
152
153 To get a trusted certificate (CA or Certificate Authority signed
154 certificate), you will either need to purchase certificates signed by a
155 commercial CA or find a friend that has setup his own CA or become a CA
156 yourself, and thus you can sign all your own certificates.  The book
157 OpenSSL by John Viega, Matt Mesier \& Pravir Chandra from O'Reilly explains
158 how to do it, or you can read the documentation provided in the Open-source
159 PKI Book project at Source Forge: \elink{http://ospkibook.sourceforge.net/docs/OSPKI-2.4.7/OSPKI-html/ospki-book.htm}{http://ospkibook.sourceforge.net/docs/OSPKI-2.4.7/OSPKI-html/ospki-book.htm}.
160 Note, this link may change. 
161
162 The program TinyCA has a very nice Graphical User Interface 
163 that allows you to easily setup and maintain your own CA.
164 TinyCA can be found at
165 \elink{http://tinyca.sm-zone.net/}{http://tinyca.sm-zone.net/}.
166
167
168 \section{Getting a CA Signed Certificate}
169 \index[general]{Certificate!Getting a CA Signed }
170 \index[general]{Getting a CA Signed Certificate }
171
172 The process of getting a certificate that is signed by a CA is quite a bit
173 more complicated. You can purchase one from quite a number of PKI vendors, but
174 that is not at all necessary for use with Bacula. To get a CA signed
175 certificate, you will either need to find a friend that has setup his own CA
176 or to become a CA yourself, and thus you can sign all your own certificates.
177 The book OpenSSL by John Viega, Matt Mesier \& Pravir Chandra from O'Reilly
178 explains how to do it, or you can read the documentation provided in the
179 Open-source PKI Book project at Source Forge: 
180 \elink{http://ospkibook.sourceforge.net/docs/OSPKI-2.4.7/OSPKI-html/ospki-book.htm}{http://ospkibook.sourceforge.net/docs/OSPKI-2.4.7/OSPKI-html/ospki-book.htm}.
181 Note, this link may change. 
182
183 \section{Example TLS Configuration Files}
184 \index[general]{Example!TLS Configuration Files}
185 \index[general]{TLS Configuration Files}
186
187 Landon has supplied us with the TLS portions of his configuration
188 files, which should help you setting up your own.  Note, this example
189 shows the directives necessary for a Director to Storage daemon session.
190 The technique is the same between the Director and the Client and
191 for bconsole to the Director.
192
193 {\bf bacula-dir.conf}
194 \footnotesize
195 \begin{verbatim}
196    Director {                            # define myself
197      Name = backup1-dir
198      ...
199      TLS Enable = yes
200      TLS Require = yes
201      TLS Verify Peer = yes
202      TLS Allowed CN = "bacula@backup1.example.com"
203      TLS Allowed CN = "administrator@example.com"
204      TLS CA Certificate File = /usr/local/etc/ssl/ca.pem
205      # This is a server certificate, used for incoming
206      # console connections.
207      TLS Certificate = /usr/local/etc/ssl/backup1/cert.pem
208      TLS Key = /usr/local/etc/ssl/backup1/key.pem
209    }
210
211    Storage {
212      Name = File
213      Address = backup1.example.com
214      ...
215      TLS Require = yes
216      TLS CA Certificate File = /usr/local/etc/ssl/ca.pem
217      # This is a client certificate, used by the director to
218      # connect to the storage daemon
219      TLS Certificate = /usr/local/etc/ssl/bacula@backup1/cert.pem
220      TLS Key = /usr/local/etc/ssl/bacula@backup1/key.pem
221    }
222
223    Client {
224      Name = backup1-fd
225      Address = server1.example.com
226      ...
227    
228      TLS Enable = yes
229      TLS Require = yes
230      TLS CA Certificate File = /usr/local/etc/ssl/ca.pem
231    }
232
233 \end{verbatim}
234 \normalsize
235
236 {\bf bacula-fd.conf}
237 \footnotesize
238 \begin{verbatim}
239    Director {
240      Name = backup1-dir
241      ...
242      TLS Enable = yes
243      TLS Require = yes
244      TLS Verify Peer = yes
245      # Allow only the Director to connect
246      TLS Allowed CN = "bacula@backup1.example.com"
247      TLS CA Certificate File = /usr/local/etc/ssl/ca.pem
248      # This is a server certificate. It is used by connecting
249      # directors to verify the authenticity of this file daemon
250      TLS Certificate = /usr/local/etc/ssl/server1/cert.pem
251      TLS Key = /usr/local/etc/ssl/server1/key.pem
252    }
253
254   FileDaemon {
255      Name = backup1-fd
256      ...
257      # you need these TLS entries so the SD and FD can
258      # communicate
259      TLS Enable = yes
260      TLS Require = yes
261
262      TLS CA Certificate File = /usr/local/etc/ssl/ca.pem
263      TLS Certificate = /usr/local/etc/ssl/server1/cert.pem
264      TLS Key = /usr/local/etc/ssl/server1/key.pem
265 }
266 \end{verbatim}
267 \normalsize
268
269 {\bf bacula-sd.conf}
270 \footnotesize
271 \begin{verbatim}
272    Storage {                             # definition of myself
273      Name = backup1-sd
274      ...
275      # These TLS configuration options are used for incoming
276      # file daemon connections. Director TLS settings are handled
277      # below.
278      TLS Enable = yes
279      TLS Require = yes
280      # Peer certificate is not required/requested -- peer validity
281      # is verified by the storage connection cookie provided to the
282      # File Daemon by the director.
283      TLS Verify Peer = no
284      TLS CA Certificate File = /usr/local/etc/ssl/ca.pem
285      # This is a server certificate. It is used by connecting
286      # file daemons to verify the authenticity of this storage daemon
287      TLS Certificate = /usr/local/etc/ssl/backup1/cert.pem
288      TLS Key = /usr/local/etc/ssl/backup1/key.pem
289    }
290
291    #
292    # List Directors who are permitted to contact Storage daemon
293    #
294    Director {
295      Name = backup1-dir
296      ...
297      TLS Enable = yes
298      TLS Require = yes
299      # Require the connecting director to provide a certificate
300      # with the matching CN.
301      TLS Verify Peer = yes
302      TLS Allowed CN = "bacula@backup1.example.com"
303      TLS CA Certificate File = /usr/local/etc/ssl/ca.pem
304      # This is a server certificate. It is used by the connecting
305      # director to verify the authenticity of this storage daemon
306      TLS Certificate = /usr/local/etc/ssl/backup1/cert.pem
307      TLS Key = /usr/local/etc/ssl/backup1/key.pem
308    }
309 \end{verbatim}
310 \normalsize