@@ -40,6 +40,8 @@ The following parameters are commonly used:
4040 ``dbtableprefix ``
4141* ``adminlogin `` and ``adminpass ``
4242* optionally, ``trusted_domains `` and ``adminemail ``
43+ * optionally, the parameters of an
44+ :ref: `encrypted database connection <autoconfig_database_encryption_label >`
4345
4446Two parameters have different names from their corresponding
4547:file: `config.php ` settings:
@@ -52,6 +54,70 @@ Two parameters have different names from their corresponding
5254| ``dbpass `` | ``dbpassword `` |
5355+--------------------+-------------------+
5456
57+ .. _autoconfig_database_encryption_label :
58+
59+ Encrypted database connection
60+ -----------------------------
61+
62+ .. versionadded :: 35
63+
64+ An SSL/TLS encrypted connection to the database server can be configured during
65+ the installation. Use this when the database does not run on the same host as
66+ Nextcloud, so that the credentials and all queries are not sent in plaintext.
67+
68+ The following parameters are independent of the database backend. Nextcloud
69+ translates them into the corresponding :file: `config.php ` settings before the
70+ first connection is opened, so the installation itself already uses an
71+ encrypted connection.
72+
73+ .. list-table :: Connection encryption parameters
74+ :header-rows: 1
75+ :widths: 20 20 60
76+
77+ * - Parameter
78+ - Supported by
79+ - Description
80+ * - ``dbsslmode ``
81+ - PostgreSQL
82+ - Encryption mode of the connection, for example ``require `` or
83+ ``verify-full ``. See the `PostgreSQL documentation
84+ <https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS> `_
85+ for the available modes.
86+ * - ``dbsslca ``
87+ - MySQL/MariaDB, PostgreSQL
88+ - Path to the CA certificate the database server is verified against.
89+ * - ``dbsslcert ``
90+ - MySQL/MariaDB, PostgreSQL
91+ - Path to the client certificate used to authenticate against the
92+ database server.
93+ * - ``dbsslkey ``
94+ - MySQL/MariaDB, PostgreSQL
95+ - Path to the private key belonging to the client certificate.
96+ * - ``dbsslcrl ``
97+ - PostgreSQL
98+ - Path to the certificate revocation list.
99+ * - ``dbsslnoverify ``
100+ - MySQL/MariaDB
101+ - Set to ``true `` to not verify that the certificate of the database
102+ server matches the hostname used to connect. MySQL and MariaDB verify
103+ this by default, PostgreSQL only in the ``verify-full `` mode.
104+
105+ Note the following restrictions:
106+
107+ * ``dbsslcert `` and ``dbsslkey `` have to be provided together.
108+ * A parameter that the selected database does not support is rejected with an
109+ error instead of being ignored, and the installation does not proceed.
110+ SQLite and Oracle support none of them — an Oracle connection is encrypted
111+ through the connect string and :file: `sqlnet.ora ` instead.
112+ * The certificates and keys have to be readable by the PHP process.
113+
114+ Alternatively, the backend-specific ``dbdriveroptions `` (MySQL/MariaDB) and
115+ ``pgsql_ssl `` (PostgreSQL) settings, as documented in
116+ :doc: `../configuration_server/config_sample_php_parameters `, can be written to
117+ :file: `autoconfig.php ` verbatim. They are passed to :file: `config.php ` as
118+ provided and are not validated. Values set through the parameters above take
119+ precedence over individual entries of these arrays.
120+
55121Examples
56122--------
57123
@@ -122,6 +188,53 @@ directory and administrator-account settings in the setup form.
122188 "dbtableprefix" => "",
123189 ];
124190
191+ Encrypted MySQL / MariaDB connection
192+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
193+
194+ This configuration connects to a remote MySQL or MariaDB server over an
195+ encrypted connection, verifying the server against a CA certificate and
196+ authenticating with a client certificate.
197+
198+ .. code-block :: php
199+
200+ <?php
201+ $AUTOCONFIG = [
202+ "dbtype" => "mysql",
203+ "dbname" => "nextcloud",
204+ "dbuser" => "username",
205+ "dbpass" => "password",
206+ "dbhost" => "db.example.com",
207+ "dbtableprefix" => "",
208+ "dbsslca" => "/etc/ssl/nextcloud/ca-cert.pem",
209+ "dbsslcert" => "/etc/ssl/nextcloud/client-cert.pem",
210+ "dbsslkey" => "/etc/ssl/nextcloud/client-key.pem",
211+ ];
212+
213+ Nextcloud stores these paths as ``dbdriveroptions `` in :file: `config.php `.
214+
215+ Encrypted PostgreSQL connection
216+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
217+
218+ This configuration requires an encrypted connection to a remote PostgreSQL
219+ server and verifies both the certificate of the server and the hostname it was
220+ issued for.
221+
222+ .. code-block :: php
223+
224+ <?php
225+ $AUTOCONFIG = [
226+ "dbtype" => "pgsql",
227+ "dbname" => "nextcloud",
228+ "dbuser" => "username",
229+ "dbpass" => "password",
230+ "dbhost" => "db.example.com",
231+ "dbtableprefix" => "",
232+ "dbsslmode" => "verify-full",
233+ "dbsslca" => "/etc/ssl/nextcloud/ca-cert.pem",
234+ ];
235+
236+ Nextcloud stores these values as ``pgsql_ssl `` in :file: `config.php `.
237+
125238Complete non-interactive setup
126239^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127240
0 commit comments