Skip to content

Commit 46c667d

Browse files
beneschpetrosagg
authored andcommitted
Add options for specifying SSL certificates inline
This is often quite a bit more convenient than mucking with files on disk, as it allows the URL to be fully self contained.
1 parent cc77e6e commit 46c667d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tokio-postgres/src/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,14 @@ pub enum Host {
123123
/// * `options` - Command line options used to configure the server.
124124
/// * `application_name` - Sets the `application_name` parameter on the server.
125125
/// * `sslcert` - Location of the client SSL certificate file.
126+
/// * `sslcert_inline` - The contents of the client SSL certificate.
126127
/// * `sslkey` - Location for the secret key file used for the client certificate.
128+
/// * `sslkey_inline` - The contents of the client SSL key.
127129
/// * `sslmode` - Controls usage of TLS. If set to `disable`, TLS will not be used. If set to `prefer`, TLS will be used
128130
/// if available, but not used otherwise. If set to `require`, `verify-ca`, or `verify-full`, TLS will be forced to
129131
/// be used. Defaults to `prefer`.
130132
/// * `sslrootcert` - Location of SSL certificate authority (CA) certificate.
133+
/// * `sslrootcert_inline` - The contents of the SSL certificate authority.
131134
/// * `host` - The host to connect to. On Unix platforms, if the host starts with a `/` character it is treated as the
132135
/// path to the directory containing Unix domain sockets. Otherwise, it is treated as a hostname. Multiple hosts
133136
/// can be specified, separated by commas. Each host will be tried in turn when connecting. Required if connecting
@@ -638,6 +641,9 @@ impl Config {
638641
return Err(Error::config_parse(Box::new(InvalidValue("sslcert"))));
639642
}
640643
},
644+
"sslcert_inline" => {
645+
self.ssl_cert(value.as_bytes());
646+
}
641647
"sslkey" => match std::fs::read(value) {
642648
Ok(contents) => {
643649
self.ssl_key(&contents);
@@ -646,6 +652,9 @@ impl Config {
646652
return Err(Error::config_parse(Box::new(InvalidValue("sslkey"))));
647653
}
648654
},
655+
"sslkey_inline" => {
656+
self.ssl_key(value.as_bytes());
657+
}
649658
"sslmode" => {
650659
let mode = match value {
651660
"disable" => SslMode::Disable,
@@ -665,6 +674,9 @@ impl Config {
665674
return Err(Error::config_parse(Box::new(InvalidValue("sslrootcert"))));
666675
}
667676
},
677+
"sslrootcert_inline" => {
678+
self.ssl_root_cert(value.as_bytes());
679+
}
668680
"host" => {
669681
for host in value.split(',') {
670682
self.host(host);

0 commit comments

Comments
 (0)