@@ -1047,6 +1047,10 @@ pub struct TlsOptions {
1047
1047
/// The default value is to error on invalid hostnames.
1048
1048
#[ cfg( feature = "openssl-tls" ) ]
1049
1049
pub allow_invalid_hostnames : Option < bool > ,
1050
+
1051
+ /// If set, the key in `cert_key_file_path` must be encrypted with this password.
1052
+ #[ cfg( feature = "cert-key-password" ) ]
1053
+ pub tls_certificate_key_file_password : Option < Vec < u8 > > ,
1050
1054
}
1051
1055
1052
1056
impl TlsOptions {
@@ -1064,6 +1068,8 @@ impl TlsOptions {
1064
1068
tlscafile : Option < & ' a str > ,
1065
1069
tlscertificatekeyfile : Option < & ' a str > ,
1066
1070
tlsallowinvalidcertificates : Option < bool > ,
1071
+ #[ cfg( feature = "cert-key-password" ) ]
1072
+ tlscertificatekeyfilepassword : Option < & ' a str > ,
1067
1073
}
1068
1074
1069
1075
let state = TlsOptionsHelper {
@@ -1077,6 +1083,11 @@ impl TlsOptions {
1077
1083
. as_ref ( )
1078
1084
. map ( |s| s. to_str ( ) . unwrap ( ) ) ,
1079
1085
tlsallowinvalidcertificates : tls_options. allow_invalid_certificates ,
1086
+ #[ cfg( feature = "cert-key-password" ) ]
1087
+ tlscertificatekeyfilepassword : tls_options
1088
+ . tls_certificate_key_file_password
1089
+ . as_deref ( )
1090
+ . map ( |b| std:: str:: from_utf8 ( b) . unwrap ( ) ) ,
1080
1091
} ;
1081
1092
state. serialize ( serializer)
1082
1093
}
@@ -2126,6 +2137,25 @@ impl ConnectionString {
2126
2137
) )
2127
2138
}
2128
2139
} ,
2140
+ #[ cfg( feature = "cert-key-password" ) ]
2141
+ "tlscertificatekeyfilepassword" => match & mut self . tls {
2142
+ Some ( Tls :: Disabled ) => {
2143
+ return Err ( ErrorKind :: InvalidArgument {
2144
+ message : "'tlsCertificateKeyFilePassword' can't be set if tls=false" . into ( ) ,
2145
+ }
2146
+ . into ( ) ) ;
2147
+ }
2148
+ Some ( Tls :: Enabled ( options) ) => {
2149
+ options. tls_certificate_key_file_password = Some ( value. as_bytes ( ) . to_vec ( ) ) ;
2150
+ }
2151
+ None => {
2152
+ self . tls = Some ( Tls :: Enabled (
2153
+ TlsOptions :: builder ( )
2154
+ . tls_certificate_key_file_password ( value. as_bytes ( ) . to_vec ( ) )
2155
+ . build ( ) ,
2156
+ ) )
2157
+ }
2158
+ } ,
2129
2159
"uuidrepresentation" => match value. to_lowercase ( ) . as_str ( ) {
2130
2160
"csharplegacy" => self . uuid_representation = Some ( UuidRepresentation :: CSharpLegacy ) ,
2131
2161
"javalegacy" => self . uuid_representation = Some ( UuidRepresentation :: JavaLegacy ) ,
0 commit comments