@@ -1057,6 +1057,10 @@ pub struct TlsOptions {
10571057 /// The default value is to error on invalid hostnames.
10581058 #[ cfg( feature = "openssl-tls" ) ]
10591059 pub allow_invalid_hostnames : Option < bool > ,
1060+
1061+ /// If set, the key in `cert_key_file_path` must be encrypted with this password.
1062+ #[ cfg( feature = "cert-key-password" ) ]
1063+ pub tls_certificate_key_file_password : Option < Vec < u8 > > ,
10601064}
10611065
10621066impl TlsOptions {
@@ -1074,6 +1078,8 @@ impl TlsOptions {
10741078 tlscafile : Option < & ' a str > ,
10751079 tlscertificatekeyfile : Option < & ' a str > ,
10761080 tlsallowinvalidcertificates : Option < bool > ,
1081+ #[ cfg( feature = "cert-key-password" ) ]
1082+ tlscertificatekeyfilepassword : Option < & ' a str > ,
10771083 }
10781084
10791085 let state = TlsOptionsHelper {
@@ -1087,6 +1093,11 @@ impl TlsOptions {
10871093 . as_ref ( )
10881094 . map ( |s| s. to_str ( ) . unwrap ( ) ) ,
10891095 tlsallowinvalidcertificates : tls_options. allow_invalid_certificates ,
1096+ #[ cfg( feature = "cert-key-password" ) ]
1097+ tlscertificatekeyfilepassword : tls_options
1098+ . tls_certificate_key_file_password
1099+ . as_deref ( )
1100+ . map ( |b| std:: str:: from_utf8 ( b) . unwrap ( ) ) ,
10901101 } ;
10911102 state. serialize ( serializer)
10921103 }
@@ -2328,6 +2339,25 @@ impl ConnectionString {
23282339 ) )
23292340 }
23302341 } ,
2342+ #[ cfg( feature = "cert-key-password" ) ]
2343+ "tlscertificatekeyfilepassword" => match & mut self . tls {
2344+ Some ( Tls :: Disabled ) => {
2345+ return Err ( ErrorKind :: InvalidArgument {
2346+ message : "'tlsCertificateKeyFilePassword' can't be set if tls=false" . into ( ) ,
2347+ }
2348+ . into ( ) ) ;
2349+ }
2350+ Some ( Tls :: Enabled ( options) ) => {
2351+ options. tls_certificate_key_file_password = Some ( value. as_bytes ( ) . to_vec ( ) ) ;
2352+ }
2353+ None => {
2354+ self . tls = Some ( Tls :: Enabled (
2355+ TlsOptions :: builder ( )
2356+ . tls_certificate_key_file_password ( value. as_bytes ( ) . to_vec ( ) )
2357+ . build ( ) ,
2358+ ) )
2359+ }
2360+ } ,
23312361 "uuidrepresentation" => match value. to_lowercase ( ) . as_str ( ) {
23322362 "csharplegacy" => self . uuid_representation = Some ( UuidRepresentation :: CSharpLegacy ) ,
23332363 "javalegacy" => self . uuid_representation = Some ( UuidRepresentation :: JavaLegacy ) ,
0 commit comments