]>
Commit | Line | Data |
---|---|---|
4b9ba26d SF |
1 | .. |
2 | Licensed under the Apache License, Version 2.0 (the "License"); you may | |
3 | not use this file except in compliance with the License. You may obtain | |
4 | a copy of the License at | |
5 | ||
6 | http://www.apache.org/licenses/LICENSE-2.0 | |
7 | ||
8 | Unless required by applicable law or agreed to in writing, software | |
9 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
10 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
11 | License for the specific language governing permissions and limitations | |
12 | under the License. | |
13 | ||
14 | Convention for heading levels in Open vSwitch documentation: | |
15 | ||
16 | ======= Heading 0 (reserved for the title in a document) | |
17 | ------- Heading 1 | |
18 | ~~~~~~~ Heading 2 | |
19 | +++++++ Heading 3 | |
20 | ''''''' Heading 4 | |
21 | ||
22 | Avoid deeper levels because they do not render well. | |
23 | ||
24 | ===================== | |
25 | Open vSwitch with SSL | |
26 | ===================== | |
27 | ||
28 | If you plan to configure Open vSwitch to connect across the network to an | |
29 | OpenFlow controller, then we recommend that you build Open vSwitch with | |
30 | OpenSSL. SSL support ensures integrity and confidentiality of the OpenFlow | |
31 | connections, increasing network security. | |
32 | ||
33 | This document describes how to configure an Open vSwitch to connect to an | |
795752a3 SF |
34 | OpenFlow controller over SSL. Refer to :doc:`/intro/install/general`. for |
35 | instructions on building Open vSwitch with SSL support. | |
4b9ba26d SF |
36 | |
37 | Open vSwitch uses TLS version 1.0 or later (TLSv1), as specified by RFC 2246, | |
38 | which is very similar to SSL version 3.0. TLSv1 was released in January 1999, | |
39 | so all current software and hardware should implement it. | |
40 | ||
41 | This document assumes basic familiarity with public-key cryptography and | |
42 | public-key infrastructure. | |
43 | ||
44 | SSL Concepts for OpenFlow | |
45 | ------------------------- | |
46 | ||
47 | This section is an introduction to the public-key infrastructure architectures | |
48 | that Open vSwitch supports for SSL authentication. | |
49 | ||
50 | To connect over SSL, every Open vSwitch must have a unique private/public key | |
51 | pair and a certificate that signs that public key. Typically, the Open vSwitch | |
52 | generates its own public/private key pair. There are two common ways to obtain | |
53 | a certificate for a switch: | |
54 | ||
55 | * Self-signed certificates: The Open vSwitch signs its certificate with its own | |
56 | private key. In this case, each switch must be individually approved by the | |
57 | OpenFlow controller(s), since there is no central authority. | |
58 | ||
59 | This is the only switch PKI model currently supported by NOX | |
60 | (http://noxrepo.org). | |
61 | ||
62 | * Switch certificate authority: A certificate authority (the "switch CA") signs | |
63 | each Open vSwitch's public key. The OpenFlow controllers then check that any | |
64 | connecting switches' certificates are signed by that certificate authority. | |
65 | ||
66 | This is the only switch PKI model supported by the simple OpenFlow controller | |
67 | included with Open vSwitch. | |
68 | ||
69 | Each Open vSwitch must also have a copy of the CA certificate for the | |
70 | certificate authority that signs OpenFlow controllers' keys (the "controller | |
71 | CA" certificate). Typically, the same controller CA certificate is installed | |
72 | on all of the switches within a given administrative unit. There are two | |
73 | common ways for a switch to obtain the controller CA certificate: | |
74 | ||
75 | * Manually copy the certificate to the switch through some secure means, e.g. | |
76 | using a USB flash drive, or over the network with "scp", or even FTP or HTTP | |
77 | followed by manual verification. | |
78 | ||
79 | * Open vSwitch "bootstrap" mode, in which Open vSwitch accepts and saves the | |
80 | controller CA certificate that it obtains from the OpenFlow controller on its | |
81 | first connection. Thereafter the switch will only connect to controllers | |
82 | signed by the same CA certificate. | |
83 | ||
84 | Establishing a Public Key Infrastructure | |
85 | ---------------------------------------- | |
86 | ||
87 | Open vSwitch can make use of your existing public key infrastructure. If you | |
88 | already have a PKI, you may skip forward to the next section. Otherwise, if | |
89 | you do not have a PKI, the ovs-pki script included with Open vSwitch can help. | |
90 | To create an initial PKI structure, invoke it as: | |
91 | ||
92 | :: | |
93 | ||
94 | $ ovs-pki init | |
95 | ||
96 | This will create and populate a new PKI directory. The default location for | |
97 | the PKI directory depends on how the Open vSwitch tree was configured (to see | |
98 | the configured default, look for the ``--dir`` option description in the output | |
99 | of ``ovs-pki --help``). | |
100 | ||
101 | The pki directory contains two important subdirectories. The `controllerca` | |
102 | subdirectory contains controller CA files, including the following: | |
103 | ||
104 | `cacert.pem` | |
105 | Root certificate for the controller certificate authority. Each Open vSwitch | |
106 | must have a copy of this file to allow it to authenticate valid controllers. | |
107 | ||
108 | `private/cakey.pem` | |
109 | Private signing key for the controller certificate authority. This file must | |
110 | be kept secret. There is no need for switches or controllers to have a copy | |
111 | of it. | |
112 | ||
113 | The `switchca` subdirectory contains switch CA files, analogous to those in the | |
114 | `controllerca` subdirectory: | |
115 | ||
116 | `cacert.pem` | |
117 | Root certificate for the switch certificate authority. The OpenFlow | |
118 | controller must have this file to enable it to authenticate valid switches. | |
119 | ||
120 | `private/cakey.pem` | |
121 | Private signing key for the switch certificate authority. This file must be | |
122 | kept secret. There is no need for switches or controllers to have a copy of | |
123 | it. | |
124 | ||
125 | After you create the initial structure, you can create keys and certificates | |
126 | for switches and controllers with ovs-pki. Refer to the ovs-pki(8) manage for | |
127 | complete details. A few examples of its use follow: | |
128 | ||
129 | Controller Key Generation | |
130 | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
131 | ||
132 | To create a controller private key and certificate in files named | |
133 | ctl-privkey.pem and ctl-cert.pem, run the following on the machine that | |
134 | contains the PKI structure: | |
135 | ||
136 | :: | |
137 | ||
138 | $ ovs-pki req+sign ctl controller | |
139 | ||
140 | ctl-privkey.pem and ctl-cert.pem would need to be copied to the controller for | |
141 | its use at runtime. If, for testing purposes, you were to use | |
142 | ovs-testcontroller, the simple OpenFlow controller included with Open vSwitch, | |
143 | then the --private-key and --certificate options, respectively, would point to | |
144 | these files. | |
145 | ||
146 | It is very important to make sure that no stray copies of ctl-privkey.pem are | |
147 | created, because they could be used to impersonate the controller. | |
148 | ||
149 | Switch Key Generation with Self-Signed Certificates | |
150 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
151 | ||
152 | If you are using self-signed certificates (see "SSL Concepts for OpenFlow"), | |
153 | this is one way to create an acceptable certificate for your controller to | |
154 | approve. | |
155 | ||
156 | 1. Run the following command on the Open vSwitch itself:: | |
157 | ||
158 | $ ovs-pki self-sign sc | |
159 | ||
160 | .. note:: | |
161 | This command does not require a copy of any of the PKI files generated by | |
162 | ``ovs-pki init``, and you should not copy them to the switch because some | |
163 | of them have contents that must remain secret for security.) | |
164 | ||
165 | The ``ovs-pki self-sign`` command has the following output: | |
166 | ||
167 | sc-privkey.pem | |
168 | the switch private key file. For security, the contents of this file must | |
169 | remain secret. There is ordinarily no need to copy this file off the Open | |
170 | vSwitch. | |
171 | ||
172 | sc-cert.pem | |
173 | the switch certificate, signed by the switch's own private key. Its | |
174 | contents are not a secret. | |
175 | ||
176 | 2. Optionally, copy `controllerca/cacert.pem` from the machine that has the | |
177 | OpenFlow PKI structure and verify that it is correct. (Otherwise, you will | |
178 | have to use CA certificate bootstrapping when you configure Open vSwitch in | |
179 | the next step.) | |
180 | ||
181 | 3. Configure Open vSwitch to use the keys and certificates (see "Configuring | |
182 | SSL Support", below). | |
183 | ||
184 | Switch Key Generation with a Switch PKI (Easy Method) | |
185 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
186 | ||
187 | If you are using a switch PKI (see "SSL Concepts for OpenFlow", above), this | |
188 | method of switch key generation is a little easier than the alternate method | |
189 | described below, but it is also a little less secure because it requires | |
190 | copying a sensitive private key from file from the machine hosting the PKI to | |
191 | the switch. | |
192 | ||
193 | 1. Run the following on the machine that contains the PKI structure:: | |
194 | ||
195 | $ ovs-pki req+sign sc switch | |
196 | ||
197 | This command has the following output: | |
198 | ||
199 | sc-privkey.pem | |
200 | the switch private key file. For security, the contents of this file must | |
201 | remain secret. | |
202 | ||
203 | sc-cert.pem | |
204 | the switch certificate. Its contents are not a secret. | |
205 | ||
206 | 2. Copy sc-privkey.pem and sc-cert.pem, plus controllerca/cacert.pem, to the | |
207 | Open vSwitch. | |
208 | ||
209 | 3. Delete the copies of sc-privkey.pem and sc-cert.pem on the PKI machine and | |
210 | any other copies that may have been made in transit. It is very important | |
211 | to make sure that there are no stray copies of sc-privkey.pem, because they | |
212 | could be used to impersonate the switch. | |
213 | ||
214 | .. warning:: | |
215 | Don't delete controllerca/cacert.pem! It is not security-sensitive and | |
216 | you will need it to configure additional switches. | |
217 | ||
218 | 4. Configure Open vSwitch to use the keys and certificates (see "Configuring | |
219 | SSL Support", below). | |
220 | ||
221 | Switch Key Generation with a Switch PKI (More Secure) | |
222 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
223 | ||
224 | If you are using a switch PKI (see "SSL Concepts for OpenFlow", above), then, | |
225 | compared to the previous method, the method described here takes a little more | |
226 | work, but it does not involve copying the private key from one machine to | |
227 | another, so it may also be a little more secure. | |
228 | ||
229 | 1. Run the following command on the Open vSwitch itself:: | |
230 | ||
231 | $ ovs-pki req sc | |
232 | ||
233 | .. note:: | |
234 | This command does not require a copy of any of the PKI files generated by | |
235 | "ovs-pki init", and you should not copy them to the switch because some of | |
236 | them have contents that must remain secret for security. | |
237 | ||
238 | The "ovs-pki req" command has the following output: | |
239 | ||
240 | sc-privkey.pem | |
241 | the switch private key file. For security, the contents of this file must | |
242 | remain secret. There is ordinarily no need to copy this file off the Open | |
243 | vSwitch. | |
244 | ||
245 | sc-req.pem | |
246 | the switch "certificate request", which is essentially the switch's public | |
247 | key. Its contents are not a secret. | |
248 | ||
249 | a fingerprint | |
250 | this is output on stdout. | |
251 | ||
252 | 2. Write the fingerprint down on a slip of paper and copy `sc-req.pem` to the | |
253 | machine that contains the PKI structure. | |
254 | ||
255 | 3. On the machine that contains the PKI structure, run:: | |
256 | ||
257 | $ ovs-pki sign sc switch | |
258 | ||
259 | This command will output a fingerprint to stdout and request that you verify | |
260 | it. Check that it is the same as the fingerprint that you wrote down on the | |
261 | slip of paper before you answer "yes". | |
262 | ||
263 | ``ovs-pki sign`` creates a file named `sc-cert.pem`, which is the switch | |
264 | certificate. Its contents are not a secret. | |
265 | ||
266 | 4. Copy the generated `sc-cert.pem`, plus `controllerca/cacert.pem` from the | |
267 | PKI structure, to the Open vSwitch, and verify that they were copied | |
268 | correctly. | |
269 | ||
270 | You may delete `sc-cert.pem` from the machine that hosts the PKI | |
271 | structure now, although it is not important that you do so. | |
272 | ||
273 | .. warning:: | |
274 | Don't delete `controllerca/cacert.pem`! It is not security-sensitive and | |
275 | you will need it to configure additional switches. | |
276 | ||
277 | 5. Configure Open vSwitch to use the keys and certificates (see "Configuring | |
278 | SSL Support", below). | |
279 | ||
280 | Configuring SSL Support | |
281 | ----------------------- | |
282 | ||
283 | SSL configuration requires three additional configuration files. The first two | |
284 | of these are unique to each Open vSwitch. If you used the instructions above | |
285 | to build your PKI, then these files will be named `sc-privkey.pem` and | |
286 | `sc-cert.pem`, respectively: | |
287 | ||
288 | - A private key file, which contains the private half of an RSA or DSA key. | |
289 | ||
290 | This file can be generated on the Open vSwitch itself, for the greatest | |
291 | security, or it can be generated elsewhere and copied to the Open vSwitch. | |
292 | ||
293 | The contents of the private key file are secret and must not be exposed. | |
294 | ||
295 | - A certificate file, which certifies that the private key is that of a | |
296 | trustworthy Open vSwitch. | |
297 | ||
298 | This file has to be generated on a machine that has the private key for the | |
299 | switch certification authority, which should not be an Open vSwitch; ideally, | |
300 | it should be a machine that is not networked at all. | |
301 | ||
302 | The certificate file itself is not a secret. | |
303 | ||
304 | The third configuration file is typically the same across all the switches in a | |
305 | given administrative unit. If you used the instructions above to build your | |
306 | PKI, then this file will be named `cacert.pem`: | |
307 | ||
308 | - The root certificate for the controller certificate authority. The Open | |
309 | vSwitch verifies it that is authorized to connect to an OpenFlow controller | |
310 | by verifying a signature against this CA certificate. | |
311 | ||
312 | Once you have these files, configure ovs-vswitchd to use them using the | |
313 | ``ovs-vsctl set-ssl`` command, e.g.:: | |
314 | ||
315 | $ ovs-vsctl set-ssl /etc/openvswitch/sc-privkey.pem \ | |
316 | /etc/openvswitch/sc-cert.pem /etc/openvswitch/cacert.pem | |
317 | ||
318 | Substitute the correct file names, of course, if they differ from the ones used | |
319 | above. You should use absolute file names (ones that begin with ``/``), | |
320 | because ovs-vswitchd's current directory is unrelated to the one from which you | |
321 | run ovs-vsctl. | |
322 | ||
323 | If you are using self-signed certificates (see "SSL Concepts for OpenFlow") and | |
324 | you did not copy controllerca/cacert.pem from the PKI machine to the Open | |
325 | vSwitch, then add the ``--bootstrap`` option, e.g.:: | |
326 | ||
327 | $ ovs-vsctl -- --bootstrap set-ssl /etc/openvswitch/sc-privkey.pem \ | |
328 | /etc/openvswitch/sc-cert.pem /etc/openvswitch/cacert.pem | |
329 | ||
330 | After you have added all of these configuration keys, you may specify ``ssl:`` | |
331 | connection methods elsewhere in the configuration database. ``tcp:`` connection | |
332 | methods are still allowed even after SSL has been configured, so for security | |
333 | you should use only ``ssl:`` connections. | |
334 | ||
335 | Reporting Bugs | |
336 | -------------- | |
337 | ||
338 | Report problems to bugs@openvswitch.org. |