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