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

Commitbe48805

Browse files
committed
Added more SSL options
Signed-off-by: chandr-andr (Kiselev Aleksandr) <chandr@chandr.net>
1 parent918c100 commitbe48805

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

‎tokio-postgres/src/config.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,21 @@ pub enum TargetSessionAttrs {
4444
pubenumSslMode{
4545
/// Do not use TLS.
4646
Disable,
47+
/// Pay the overhead of encryption if the server insists on it.
48+
Allow,
4749
/// Attempt to connect with TLS but allow sessions without.
4850
Prefer,
4951
/// Require the use of TLS.
5052
Require,
53+
/// I want my data encrypted,
54+
/// and I accept the overhead.
55+
/// I want to be sure that I connect to a server that I trust.
56+
VerifyCa,
57+
/// I want my data encrypted,
58+
/// and I accept the overhead.
59+
/// I want to be sure that I connect to a server I trust,
60+
/// and that it's the one I specify.
61+
VerifyFull,
5162
}
5263

5364
/// Channel binding configuration.
@@ -542,8 +553,11 @@ impl Config {
542553
"sslmode" =>{
543554
let mode =match value{
544555
"disable" =>SslMode::Disable,
556+
"allow" =>SslMode::Allow,
545557
"prefer" =>SslMode::Prefer,
546558
"require" =>SslMode::Require,
559+
"verify-ca" =>SslMode::VerifyCa,
560+
"verify-full" =>SslMode::VerifyFull,
547561
_ =>returnErr(Error::config_parse(Box::new(InvalidValue("sslmode")))),
548562
};
549563
self.ssl_mode(mode);

‎tokio-postgres/src/connect_tls.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,17 @@ where
1919
{
2020
match mode{
2121
SslMode::Disable =>returnOk(MaybeTlsStream::Raw(stream)),
22+
SslMode::Allowif !tls.can_connect(ForcePrivateApi) =>{
23+
returnOk(MaybeTlsStream::Raw(stream))
24+
}
2225
SslMode::Preferif !tls.can_connect(ForcePrivateApi) =>{
2326
returnOk(MaybeTlsStream::Raw(stream))
2427
}
25-
SslMode::Prefer |SslMode::Require =>{}
28+
SslMode::Allow
29+
|SslMode::Prefer
30+
|SslMode::Require
31+
|SslMode::VerifyCa
32+
|SslMode::VerifyFull =>{}
2633
}
2734

2835
letmut buf =BytesMut::new();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp