@@ -195,6 +195,7 @@ pub struct SslOpts {
195
195
root_certs : Vec < PathOrBuf < ' static > > ,
196
196
skip_domain_validation : bool ,
197
197
accept_invalid_certs : bool ,
198
+ tls_hostname_override : Option < Cow < ' static , str > > ,
198
199
}
199
200
200
201
impl SslOpts {
@@ -228,6 +229,18 @@ impl SslOpts {
228
229
self
229
230
}
230
231
232
+ /// If set, will override the hostname used to verify the server's certificate.
233
+ ///
234
+ /// This is useful when connecting to a server via a tunnel, where the server hostname is
235
+ /// different from the hostname used to connect to the tunnel.
236
+ pub fn with_danger_tls_hostname_override < T : Into < Cow < ' static , str > > > (
237
+ mut self ,
238
+ domain : Option < T > ,
239
+ ) -> Self {
240
+ self . tls_hostname_override = domain. map ( Into :: into) ;
241
+ self
242
+ }
243
+
231
244
#[ cfg( any( feature = "native-tls" , feature = "rustls-tls" ) ) ]
232
245
pub fn client_identity ( & self ) -> Option < & ClientIdentity > {
233
246
self . client_identity . as_ref ( )
@@ -244,6 +257,10 @@ impl SslOpts {
244
257
pub fn accept_invalid_certs ( & self ) -> bool {
245
258
self . accept_invalid_certs
246
259
}
260
+
261
+ pub fn tls_hostname_override ( & self ) -> Option < & str > {
262
+ self . tls_hostname_override . as_deref ( )
263
+ }
247
264
}
248
265
249
266
/// Connection pool options.
0 commit comments