implement client tls certificates

fixes https://github.com/lovasoa/SQLpage/issues/300
This commit is contained in:
lovasoa
2024-05-05 00:58:01 +02:00
parent 1cb8f9455a
commit 969b2b95aa
4 changed files with 48 additions and 24 deletions
+3
View File
@@ -5,6 +5,9 @@
- Fix missing visual indication of selected item in form dropdown fields.
- ![screenshot](https://github.com/tabler/tabler/assets/552629/a575db2f-e210-4984-a786-5727687ac037)
- fix autofocus on select fields with dropdown
- Added support for SSL client certificates in MySQL and Postgres
- SSL client certificates are commonly used to secure connections to databases in cloud environments. To connect to a database that requires a client certificate, you can now use the ssl_cert and ssl_key connection options in the connection string. For example: postgres://user@host/db?ssl_cert=/path/to/client-cert.pem&ssl_key=/path/to/client-key.pem
## 0.20.4 (2024-04-23)
Generated
+19 -23
View File
@@ -1530,21 +1530,18 @@ dependencies = [
[[package]]
name = "hashlink"
version = "0.8.4"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7"
checksum = "692eaaf7f7607518dd3cef090f1474b61edc5301d8012f09579920df68b725ee"
dependencies = [
"hashbrown 0.14.5",
]
[[package]]
name = "heck"
version = "0.4.1"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
dependencies = [
"unicode-segmentation",
]
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
@@ -2888,13 +2885,13 @@ dependencies = [
[[package]]
name = "sqlx-core-oldapi"
version = "0.6.20"
version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624f048d5bd101ab562d59b9c39482b913b56e650cdddaf02261a0a4183c92ca"
checksum = "aa9a7023136d8a8f6da5ad32aa17a2069fd34f9473288f1086d6eeb4044920f8"
dependencies = [
"ahash",
"atoi",
"base64 0.21.7",
"base64 0.22.1",
"bitflags 2.5.0",
"byteorder",
"bytes",
@@ -2951,9 +2948,9 @@ dependencies = [
[[package]]
name = "sqlx-macros-oldapi"
version = "0.6.20"
version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20072fc1733434670020c0ac4aa4dded9ef63b96fe752f9c1a99e59912aaf387"
checksum = "ab0aaae6248541829f7135fad6fdc4fb45e63b25a669c002307c1411d7219b2a"
dependencies = [
"dotenvy",
"either",
@@ -2971,9 +2968,9 @@ dependencies = [
[[package]]
name = "sqlx-oldapi"
version = "0.6.20"
version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8dbf0eee6f059103c75080f9c8d2ecce0e9c5fe2038b9b83e1b84699d27cdf"
checksum = "ea211c9013de96d018ab47b5ec307b74ddaf079cba70a18bd6239b090b30e150"
dependencies = [
"sqlx-core-oldapi",
"sqlx-macros-oldapi",
@@ -2981,9 +2978,9 @@ dependencies = [
[[package]]
name = "sqlx-rt-oldapi"
version = "0.6.20"
version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "411bcba96bb1eb626546c94ec6eff6c576c995c631ffb0c1c91839c9ffd36607"
checksum = "218f0ab15a62c98c18eb5866c188688dc7df3baedb7f2a15a51761f10834f171"
dependencies = [
"once_cell",
"tokio",
@@ -3188,16 +3185,15 @@ dependencies = [
[[package]]
name = "tokio-util"
version = "0.7.10"
version = "0.7.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15"
checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1"
dependencies = [
"bytes",
"futures-core",
"futures-sink",
"pin-project-lite",
"tokio",
"tracing",
]
[[package]]
@@ -3717,18 +3713,18 @@ dependencies = [
[[package]]
name = "zerocopy"
version = "0.7.32"
version = "0.7.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
checksum = "087eca3c1eaf8c47b94d02790dd086cd594b912d2043d4de4bfdd466b3befb7c"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.7.32"
version = "0.7.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
checksum = "6f4b6c273f496d8fd4eaf18853e6b448760225dc030ff2c485a786859aea6393"
dependencies = [
"proc-macro2",
"quote",
+1 -1
View File
@@ -18,7 +18,7 @@ panic = "abort"
codegen-units = 2
[dependencies]
sqlx = { package = "sqlx-oldapi", version = "0.6.20", features = ["any", "runtime-actix-rustls", "sqlite", "postgres", "mysql", "mssql", "chrono", "json" ] }
sqlx = { package = "sqlx-oldapi", version = "0.6.22", features = ["any", "runtime-actix-rustls", "sqlite", "postgres", "mysql", "mssql", "chrono", "json" ] }
chrono = "0.4.23"
actix-web = { version = "4", features = ["rustls-0_22", "cookies"] }
percent-encoding = "2.2.0"
+25
View File
@@ -44,6 +44,31 @@ environment variable to `sqlpage=debug` to get more detailed logs and see exactl
If you have a `.env` file in the current directory or in any of its parent directories, SQLPage will automatically load environment variables from it.
### Database connection strings
The `database_url` parameter sets all the connection parameters for the database, including
- the database type (`sqlite`, `postgres`, `mysql`, `mssql`, etc.)
- the username and password
- the host (or ip adress) and port
- the database name
- any additional parameters, including
- `mode=rwc` for SQLite to allow read-write connections
- `sslmode=require` (or `disable`, `allow`, `verify-ca`, `verify-full`)
for PostgreSQL to enable or disable SSL
- `sslrootcert=/path/to/ca.pem` for PostgreSQL to specify the path to the CA certificate file
- `sslcert=/path/to/cert.pem` to specify the path to the TLS client certificate file and `sslkey=/path/to/key.pem` to specify the path to the TLS client key file for PostgreSQL and MySQL.
- `application_name=my_application` for PostgreSQL to set the application name, which can be useful for monitoring and logging on the database server side.
- `collation=utf8mb4_unicode_ci` for MySQL to set the collation of the connection
All the parameters need to be properly [percent-encoded](https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding) if they contain special characters.
A full connection string for a PostgreSQL database might look like this:
```
postgres://my_user:p%40ss@localhost:5432/my_database?sslmode=verify-ca&sslrootcert=/path/to/ca.pem&sslcert=/path/to/cert.pem&sslkey=/path/to/key.pem&application_name=my_application
```
### Example `.env` file
```bash