Skip to content

Commit 7bdd17b

Browse files
committed
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 dd70a8b commit 7bdd17b

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
@@ -102,11 +102,14 @@ pub enum Host {
102102
/// * `options` - Command line options used to configure the server.
103103
/// * `application_name` - Sets the `application_name` parameter on the server.
104104
/// * `sslcert` - Location of the client SSL certificate file.
105+
/// * `sslcert_inline` - The contents of the client SSL certificate.
105106
/// * `sslkey` - Location for the secret key file used for the client certificate.
107+
/// * `sslkey_inline` - The contents of the client SSL key.
106108
/// * `sslmode` - Controls usage of TLS. If set to `disable`, TLS will not be used. If set to `prefer`, TLS will be used
107109
/// if available, but not used otherwise. If set to `require`, `verify-ca`, or `verify-full`, TLS will be forced to
108110
/// be used. Defaults to `prefer`.
109111
/// * `sslrootcert` - Location of SSL certificate authority (CA) certificate.
112+
/// * `sslrootcert_inline` - The contents of the SSL certificate authority.
110113
/// * `host` - The host to connect to. On Unix platforms, if the host starts with a `/` character it is treated as the
111114
/// path to the directory containing Unix domain sockets. Otherwise, it is treated as a hostname. Multiple hosts
112115
/// can be specified, separated by commas. Each host will be tried in turn when connecting. Required if connecting
@@ -548,6 +551,9 @@ impl Config {
548551
return Err(Error::config_parse(Box::new(InvalidValue("sslcert"))));
549552
}
550553
},
554+
"sslcert_inline" => {
555+
self.ssl_cert(value.as_bytes());
556+
}
551557
"sslkey" => match std::fs::read(&value) {
552558
Ok(contents) => {
553559
self.ssl_key(&contents);
@@ -556,6 +562,9 @@ impl Config {
556562
return Err(Error::config_parse(Box::new(InvalidValue("sslkey"))));
557563
}
558564
},
565+
"sslkey_inline" => {
566+
self.ssl_key(value.as_bytes());
567+
}
559568
"sslmode" => {
560569
let mode = match value {
561570
"disable" => SslMode::Disable,
@@ -575,6 +584,9 @@ impl Config {
575584
return Err(Error::config_parse(Box::new(InvalidValue("sslrootcert"))));
576585
}
577586
},
587+
"sslrootcert_inline" => {
588+
self.ssl_root_cert(value.as_bytes());
589+
}
578590
"host" => {
579591
for host in value.split(',') {
580592
self.host(host);

0 commit comments

Comments
 (0)