|
2 | 2 |
|
3 | 3 | Using the `tls` module, you can generate TLS certificates and private keys. |
4 | 4 |
|
5 | | -The module has two subcommands: |
| 5 | +The module has the following subcommands: |
6 | 6 | * `rootCA` - generates a CA (certification authority) self signed certificate |
7 | 7 | and private key pair. These are to be used by a TLS server. |
8 | 8 | * `userCERT` - generates a certificate signed by a given CA, a private key and |
9 | 9 | a CA list (chain of trust) file. These are to be used by TLS clients (users). |
| 10 | +* `db_add` - adds a new TLS domain to the `tls_mgm` table. |
| 11 | +* `db_update` - changes the columns of an existing TLS domain. |
| 12 | +* `db_list` - lists the TLS domains provisioned in the `tls_mgm` table. |
| 13 | +* `db_show` - prints the columns of a TLS domain. |
| 14 | +* `db_delete` - removes a TLS domain from the `tls_mgm` table. |
| 15 | + |
| 16 | +The `db_*` subcommands provision the `tls_mgm` module over the database, where |
| 17 | +the certificate, private key and CA list are stored as BLOB values rather than |
| 18 | +as paths to files. A TLS domain is identified by its name and its type |
| 19 | +(`server` or `client`), both passed as arguments: |
| 20 | +``` |
| 21 | +opensips-cli -x tls db_delete a.example.org server |
| 22 | +``` |
| 23 | + |
| 24 | +`db_add` and `db_update` take the remaining `tls_mgm` columns as `column=value` |
| 25 | +arguments, in any order and after the domain and the type: |
| 26 | +``` |
| 27 | +opensips-cli -x tls db_add a.example.org server method=TLSv1_2 verify_cert=1 |
| 28 | +``` |
| 29 | +The settable columns are `match_ip_address`, `match_sip_domain`, `method`, |
| 30 | +`verify_cert`, `require_cert`, `certificate`, `private_key`, `crl_check_all`, |
| 31 | +`crl_dir`, `ca_list`, `ca_dir`, `cipher_list`, `dh_params` and `ec_curve`. A |
| 32 | +column that is not given is left to its default in the database schema; |
| 33 | +`db_update` only changes the columns it is given. |
| 34 | + |
| 35 | +The `certificate`, `private_key`, `ca_list` and `dh_params` columns hold PEM |
| 36 | +content, so their value is the path of the file holding it, and that file is |
| 37 | +read and stored in the table: |
| 38 | +``` |
| 39 | +opensips-cli -x tls db_add a.example.org server \ |
| 40 | + certificate=/etc/opensips/tls/user/user-cert.pem \ |
| 41 | + private_key=/etc/opensips/tls/user/user-privkey.pem |
| 42 | +``` |
| 43 | +Every other column is stored as the value it is given, paths included: for |
| 44 | +example, `ca_list` reads the file it points to, while `ca_dir` and `crl_dir` |
| 45 | +keep the directory as such, which is what `tls_mgm` expects of them. |
| 46 | + |
| 47 | +After every change, the `tls_reload` MI command is issued so that a running |
| 48 | +OpenSIPS picks up the new domains. If OpenSIPS cannot be reached, a warning is |
| 49 | +logged and the domains are loaded at the next restart. |
10 | 50 |
|
11 | 51 | ## Configuration |
12 | 52 |
|
@@ -47,6 +87,14 @@ List of `opensips-cli.cfg` settings for configuring user certificates: |
47 | 87 | * tls_user_key_size - the size of the RSA key, in bits (e.g. 4096) |
48 | 88 | * tls_user_md - the digest algorithm to use for signing (e.g. SHA256) |
49 | 89 |
|
| 90 | +List of `opensips-cli.cfg` settings for the `db_*` subcommands: |
| 91 | + |
| 92 | +* database_tls_url - URL of the database holding the `tls_mgm` table; falls |
| 93 | +back to `database_url` |
| 94 | +* database_tls_name - name of the database; falls back to `database_name` |
| 95 | +* tls_db_type - the default TLS domain type ("server" or "client"), used when |
| 96 | +no type is passed as an argument |
| 97 | + |
50 | 98 |
|
51 | 99 | ## Examples |
52 | 100 |
|
@@ -97,3 +145,39 @@ tls_user_notafter: 315360000 |
97 | 145 | tls_user_key_size: 4096 |
98 | 146 | tls_user_md: SHA256 |
99 | 147 | ``` |
| 148 | + |
| 149 | +To provision the certificate generated above as a TLS domain in the database: |
| 150 | +``` |
| 151 | +opensips-cli -x tls db_add a.example.org server \ |
| 152 | + certificate=/etc/opensips/tls/user/user-cert.pem \ |
| 153 | + private_key=/etc/opensips/tls/user/user-privkey.pem \ |
| 154 | + ca_list=/etc/opensips/tls/user/user-calist.pem |
| 155 | +``` |
| 156 | +Certificates issued by a public CA are provisioned the same way: |
| 157 | +``` |
| 158 | +opensips-cli -x tls db_add a.example.org server \ |
| 159 | + certificate=/etc/letsencrypt/live/a.example.org/fullchain.pem \ |
| 160 | + private_key=/etc/letsencrypt/live/a.example.org/privkey.pem |
| 161 | +``` |
| 162 | +Configuration file example for the `db_*` subcommands: |
| 163 | +``` |
| 164 | +[default] |
| 165 | +database_url: mysql://opensips:opensipsrw@localhost |
| 166 | +database_name: opensips |
| 167 | +tls_db_type: server |
| 168 | +``` |
| 169 | + |
| 170 | +To renew the certificate of a domain, or to change any of its other columns: |
| 171 | +``` |
| 172 | +opensips-cli -x tls db_update a.example.org server \ |
| 173 | + certificate=/etc/letsencrypt/live/a.example.org/fullchain.pem \ |
| 174 | + private_key=/etc/letsencrypt/live/a.example.org/privkey.pem |
| 175 | +opensips-cli -x tls db_update a.example.org server cipher_list=HIGH |
| 176 | +``` |
| 177 | + |
| 178 | +To inspect and remove the provisioned domains: |
| 179 | +``` |
| 180 | +opensips-cli -x tls db_list |
| 181 | +opensips-cli -x tls db_show a.example.org server |
| 182 | +opensips-cli -x tls db_delete a.example.org server |
| 183 | +``` |
0 commit comments