@@ -106,6 +106,7 @@ impl ConnectorBuilder<WantsSchemes> {
106106 ConnectorBuilder ( WantsProtocols1 {
107107 tls_config : self . 0 . tls_config ,
108108 https_only : true ,
109+ override_server_name : None ,
109110 } )
110111 }
111112
@@ -117,6 +118,7 @@ impl ConnectorBuilder<WantsSchemes> {
117118 ConnectorBuilder ( WantsProtocols1 {
118119 tls_config : self . 0 . tls_config ,
119120 https_only : false ,
121+ override_server_name : None ,
120122 } )
121123 }
122124}
@@ -128,6 +130,7 @@ impl ConnectorBuilder<WantsSchemes> {
128130pub struct WantsProtocols1 {
129131 tls_config : ClientConfig ,
130132 https_only : bool ,
133+ override_server_name : Option < String > ,
131134}
132135
133136impl WantsProtocols1 {
@@ -136,6 +139,7 @@ impl WantsProtocols1 {
136139 force_https : self . https_only ,
137140 http : conn,
138141 tls_config : std:: sync:: Arc :: new ( self . tls_config ) ,
142+ override_server_name : self . override_server_name ,
139143 }
140144 }
141145
@@ -169,6 +173,20 @@ impl ConnectorBuilder<WantsProtocols1> {
169173 enable_http1 : false ,
170174 } )
171175 }
176+
177+ /// Override server name for the TLS stack
178+ ///
179+ /// By default, for each connection hyper-rustls will extract host portion
180+ /// of the destination URL and verify that server certificate contains
181+ /// this value.
182+ ///
183+ /// If this method is called, hyper-rustls will instead verify that server
184+ /// certificate contains `override_server_name`. Domain name included in
185+ /// the URL will not affect certificate validation.
186+ pub fn with_server_name ( mut self , override_server_name : String ) -> Self {
187+ self . 0 . override_server_name = Some ( override_server_name) ;
188+ self
189+ }
172190}
173191
174192/// State of a builder with HTTP1 enabled, that may have some other
0 commit comments