File: certificates.rst

package info (click to toggle)
octavia 16.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,168 kB
  • sloc: python: 99,766; sh: 2,437; pascal: 450; makefile: 112; ruby: 18
file content (312 lines) | stat: -rw-r--r-- 11,748 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
..
      Copyright 2018 Rackspace, US Inc.

      Licensed under the Apache License, Version 2.0 (the "License"); you may
      not use this file except in compliance with the License. You may obtain a
      copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
      WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
      License for the specific language governing permissions and limitations
      under the License.

=======================================
Octavia Certificate Configuration Guide
=======================================

This document is intended for Octavia administrators setting up certificate
authorities for the two-way TLS authentication used in Octavia for command
and control of :term:`Amphora`.

This guide does not apply to the configuration of `TERMINATED_TLS` listeners
on load balancers. See the `Load Balancing Cookbook`_ for instructions on
creating `TERMINATED_TLS` listeners.

.. _Load Balancing Cookbook: ../../user/guides/basic-cookbook.html#deploy-a-tls-terminated-https-load-balancer

Two-way TLS Authentication in Octavia
=====================================

The Octavia controller processes communicate with the Amphora over
a TLS connection much like an HTTPS connection to a website. However, Octavia
validates that both sides are trusted by doing a two-way TLS authentication.

.. note::

    This is a simplification of the full TLS handshake process. See the
    `TLS 1.3 RFC 8446 <https://tools.ietf.org/html/rfc8446>`_ for the full
    handshake.

Phase One
---------

When a controller process, such as the Octavia worker process, connects to
an Amphora, the Amphora will present its `server` certificate
to the controller. The controller will then validate it against the `server`
Certificate Authority (CA) certificate stored on the controller. If the
presented certificate is validated against the `server` CA certificate, the
connection goes into phase two of the two-way TLS authentication.

Phase Two
---------

Once phase one is complete, the controller will present its `client`
certificate to the Amphora. The Amphora will then validate the
certificate against the `client` CA certificate stored inside the Amphora.
If this certificate is successfully validated, the rest of the TLS handshake
will continue to establish the secure communication channel between the
controller and the Amphora.

Certificate Lifecycles
----------------------

The `server` certificates are uniquely generated for each amphora by the
controller using the `server` certificate authority certificates and keys.
These `server` certificates are automatically rotated by the Octavia
housekeeping controller process as they near expiration.

The `client` certificates are used for the Octavia controller processes.
These are managed by the operator and due to their use on the control plane
of the cloud, typically have a long lifetime.

See the `Operator Maintenance Guide <operator-maintenance.html#rotating-cryptographic-certificates>`_ for more
information about the certificate lifecycles.

Creating the Certificate Authorities
====================================

As discussed above, this configuration uses two certificate authorities; one
for the `server` certificates, and one for the `client` certificates.

.. note::

    Technically Octavia can be run using just one certificate authority by
    using it to issue certificates for both roles. However, this weakens the
    security as a `server` certificate from an amphora could be used to
    impersonate a controller. We recommend you use two certificate authorities
    for all deployments outside of testing.

For this document we are going to setup simple OpenSSL based certificate
authorities. However, any standards compliant certificate authority software
can be used to create the required certificates.

1. Create a working directory for the certificate authorities. Make sure to
   set the proper permissions on this directory such that others cannot
   access the private keys, random bits, etc. being generated here.

   .. code-block:: bash

       $ mkdir certs
       $ chmod 700 certs
       $ cd certs

2. Create the OpenSSL configuration file. This can be shared between the
   two certificate authorities.

   .. code-block:: bash

       $ vi openssl.cnf

   .. literalinclude:: sample-configs/openssl.cnf
      :language: ini

3. Make any locally required configuration changes to the openssl.cnf. Some
   settings to consider are:

   * The default certificate lifetime is 10 years.
   * The default bit length is 2048.

4. Make directories for the two certificate authorities.

   .. code-block:: bash

       $ mkdir client_ca
       $ mkdir server_ca

5. Starting with the `server` certificate authority, prepare the CA.

   .. code-block:: bash

       $ cd server_ca
       $ mkdir certs crl newcerts private
       $ chmod 700 private
       $ touch index.txt
       $ echo 1000 > serial

6. Create the `server` CA key.

   * You will need to specify a passphrase to protect the key file.

   .. code-block:: bash

       $ openssl genpkey -algorithm RSA -out private/ca.key.pem -aes-128-cbc -pkeyopt rsa_keygen_bits:4096
       $ chmod 400 private/ca.key.pem

7. Create the `server` CA certificate.

   * You will need to specify the passphrase used in step 6.
   * You will also be asked to provide details for the certificate. These are
     up to you and should be appropriate for your organization.
   * You may want to mention this is the `server` CA in the common name field.
   * Since this is the CA certificate, you might want to give it a very long
     lifetime, such as twenty years shown in this example command.

   .. code-block:: bash

       $ openssl req -config ../openssl.cnf -key private/ca.key.pem -new -x509 -days 7300 -sha256 -extensions v3_ca -out certs/ca.cert.pem

8. Moving to the `client` certificate authority, prepare the CA.

   .. code-block:: bash

       $ cd ../client_ca
       $ mkdir certs crl csr newcerts private
       $ chmod 700 private
       $ touch index.txt
       $ echo 1000 > serial

9. Create the `client` CA key.

   * You will need to specify a passphrase to protect the key file.

   .. code-block:: bash

       $ openssl genpkey -algorithm RSA -out private/ca.key.pem -aes-128-cbc -pkeyopt rsa_keygen_bits:4096
       $ chmod 400 private/ca.key.pem

10. Create the `client` CA certificate.

    * You will need to specify the passphrase used in step 9.
    * You will also be asked to provide details for the certificate. These are
      up to you and should be appropriate for your organization.
    * You may want to mention this is the `client` CA in the common name field.
    * Since this is the CA certificate, you might want to give it a very long
      lifetime, such as twenty years shown in this example command.

    .. code-block:: bash

        $ openssl req -config ../openssl.cnf -key private/ca.key.pem -new -x509 -days 7300 -sha256 -extensions v3_ca -out certs/ca.cert.pem

11. Create a key for the `client` certificate to use.

    * You can create one certificate and key to be used by all of the
      controllers or you can create a unique certificate and key for each
      controller.
    * You will need to specify a passphrase to protect the key file.

    .. code-block:: bash

        $ openssl genpkey -algorithm RSA -out private/client.key.pem -aes-128-cbc -pkeyopt rsa_keygen_bits:2048

12. Create the certificate request for the `client` certificate used on the
    controllers.

    * You will need to specify the passphrase used in step 11.
    * You will also be asked to provide details for the certificate. These are
      up to you and should be appropriate for your organization.
    * You must fill in the common name field.
    * You may want to mention this is the `client` certificate in the common
      name field, or the individual controller information.

    .. code-block:: bash

        $ openssl req -config ../openssl.cnf -new -sha256 -key private/client.key.pem -out csr/client.csr.pem

13. Sign the `client` certificate request.

    * You will need to specify the CA passphrase used in step 9.
    * Since this certificate is used on the control plane, you might want to
      give it a very long lifetime, such as twenty years shown in this example
      command.

    .. code-block:: bash

        $ openssl ca -config ../openssl.cnf -extensions usr_cert -days 7300 -notext -md sha256 -in csr/client.csr.pem -out certs/client.cert.pem

14. Create a concatenated `client` certificate and key file.

    * You will need to specify the CA passphrase used in step 11.

    .. code-block:: bash

        $ openssl rsa -in private/client.key.pem -out private/client.cert-and-key.pem
        $ cat certs/client.cert.pem >> private/client.cert-and-key.pem


Configuring Octavia
===================

In this section we will configure Octavia to use the certificates and keys
created during the `Creating the Certificate Authorities`_ section.

1. Copy the required files over to your Octavia controllers.

   * Only the Octavia worker, health manager, and housekeeping processes will
     need access to these files.
   * The first command should return you to the "certs" directory created in
     step 1 of the `Creating the Certificate Authorities`_ section.
   * These commands assume you are running the octavia processes under the
     "octavia" user.
   * Note, some of these steps should be run with "sudo" and are indicated by
     the "#" prefix.

   .. code-block:: bash

       $ cd ..
       # mkdir /etc/octavia/certs
       # chmod 700 /etc/octavia/certs
       # cp server_ca/private/ca.key.pem /etc/octavia/certs/server_ca.key.pem
       # chmod 700 /etc/octavia/certs/server_ca.key.pem
       # cp server_ca/certs/ca.cert.pem /etc/octavia/certs/server_ca.cert.pem
       # cp client_ca/certs/ca.cert.pem /etc/octavia/certs/client_ca.cert.pem
       # cp client_ca/private/client.cert-and-key.pem /etc/octavia/certs/client.cert-and-key.pem
       # chmod 700 /etc/octavia/certs/client.cert-and-key.pem
       # chown -R octavia.octavia /etc/octavia/certs

2. Configure the [certificates] section of the octavia.conf file.

   * Only the Octavia worker, health manager, and housekeeping processes will
     need these settings.
   * The "<server CA passphrase>" should be replaced with the passphrase
     that was used in step 6 of the `Creating the Certificate Authorities`_
     section.

   .. code-block:: ini

       [certificates]
       cert_generator = local_cert_generator
       ca_certificate = /etc/octavia/certs/server_ca.cert.pem
       ca_private_key = /etc/octavia/certs/server_ca.key.pem
       ca_private_key_passphrase = <server CA key passphrase>

3. Configure the [controller_worker] section of the octavia.conf file.

   * Only the Octavia worker, health manager, and housekeeping processes will
     need these settings.

   .. code-block:: ini

       [controller_worker]
       client_ca = /etc/octavia/certs/client_ca.cert.pem

4. Configure the [haproxy_amphora] section of the octavia.conf file.

   * Only the Octavia worker, health manager, and housekeeping processes will
     need these settings.

   .. code-block:: ini

       [haproxy_amphora]
       client_cert = /etc/octavia/certs/client.cert-and-key.pem
       server_ca = /etc/octavia/certs/server_ca.cert.pem

5. Start the controller processes.

   .. code-block:: bash

       # systemctl start octavia-worker
       # systemctl start octavia-healthmanager
       # systemctl start octavia-housekeeping