@@ -1047,6 +1047,10 @@ pub struct TlsOptions {
10471047 /// The default value is to error on invalid hostnames.
10481048 #[ cfg( feature = "openssl-tls" ) ]
10491049 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 > > ,
10501054}
10511055
10521056impl TlsOptions {
@@ -1064,6 +1068,8 @@ impl TlsOptions {
10641068 tlscafile : Option < & ' a str > ,
10651069 tlscertificatekeyfile : Option < & ' a str > ,
10661070 tlsallowinvalidcertificates : Option < bool > ,
1071+ #[ cfg( feature = "cert-key-password" ) ]
1072+ tlscertificatekeyfilepassword : Option < & ' a str > ,
10671073 }
10681074
10691075 let state = TlsOptionsHelper {
@@ -1077,6 +1083,11 @@ impl TlsOptions {
10771083 . as_ref ( )
10781084 . map ( |s| s. to_str ( ) . unwrap ( ) ) ,
10791085 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 ( ) ) ,
10801091 } ;
10811092 state. serialize ( serializer)
10821093 }
@@ -2126,6 +2137,25 @@ impl ConnectionString {
21262137 ) )
21272138 }
21282139 } ,
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+ } ,
21292159 "uuidrepresentation" => match value. to_lowercase ( ) . as_str ( ) {
21302160 "csharplegacy" => self . uuid_representation = Some ( UuidRepresentation :: CSharpLegacy ) ,
21312161 "javalegacy" => self . uuid_representation = Some ( UuidRepresentation :: JavaLegacy ) ,
0 commit comments