Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit96f2347

Browse files
committed
refactor: address review comments
1 parent331e968 commit96f2347

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

‎tokio-postgres/src/config.rs‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ pub enum SslMode {
5151
}
5252

5353
/// TLS negotiation configuration
54-
#[derive(Debug,Copy,Clone,PartialEq,Eq)]
54+
///
55+
/// See more information at
56+
/// https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-SSLNEGOTIATION
57+
#[derive(Debug,Copy,Clone,PartialEq,Eq,Default)]
5558
#[non_exhaustive]
5659
pubenumSslNegotiation{
5760
/// Use PostgreSQL SslRequest for Ssl negotiation
61+
#[default]
5862
Postgres,
5963
/// Start Ssl handshake without negotiation, only works for PostgreSQL 17+
6064
Direct,
@@ -116,9 +120,15 @@ pub enum Host {
116120
/// path to the directory containing Unix domain sockets. Otherwise, it is treated as a hostname. Multiple hosts
117121
/// can be specified, separated by commas. Each host will be tried in turn when connecting. Required if connecting
118122
/// with the `connect` method.
119-
/// * `sslnegotiation` - TLS negotiation method. If set to `direct`, the client will perform direct TLS handshake, this only works for PostgreSQL 17 and newer.
120-
/// Note that you will need to setup ALPN of TLS client configuration to `postgresql` when using direct TLS.
121-
/// If set to `postgres`, the default value, it follows original postgres wire protocol to perform the negotiation.
123+
/// * `sslnegotiation` - TLS negotiation method. If set to `direct`, the client
124+
/// will perform direct TLS handshake, this only works for PostgreSQL 17 and
125+
/// newer.
126+
/// Note that you will need to setup ALPN of TLS client configuration to
127+
/// `postgresql` when using direct TLS. If you are using postgres_openssl
128+
/// as TLS backend, a `postgres_openssl::set_postgresql_alpn` helper is
129+
/// provided for that.
130+
/// If set to `postgres`, the default value, it follows original postgres
131+
/// wire protocol to perform the negotiation.
122132
/// * `hostaddr` - Numeric IP address of host to connect to. This should be in the standard IPv4 address format,
123133
/// e.g., 172.28.40.9. If your machine supports IPv6, you can also use those addresses.
124134
/// If this parameter is not specified, the value of `host` will be looked up to find the corresponding IP address,

‎tokio-postgres/src/connect_tls.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ where
2323
SslMode::Preferif !tls.can_connect(ForcePrivateApi) =>{
2424
returnOk(MaybeTlsStream::Raw(stream))
2525
}
26+
SslMode::Preferif negotiation ==SslNegotiation::Direct =>{
27+
returnErr(Error::tls("weak sslmode\"prefer\" may not be used with sslnegotiation=direct (use\"require\",\"verify-ca\", or\"verify-full\")".into()))
28+
}
2629
SslMode::Prefer |SslMode::Require =>{}
2730
}
2831

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp