@@ -106,6 +106,7 @@ impl ConnectorBuilder<WantsSchemes> {
106
106
ConnectorBuilder ( WantsProtocols1 {
107
107
tls_config : self . 0 . tls_config ,
108
108
https_only : true ,
109
+ override_server_name : None ,
109
110
} )
110
111
}
111
112
@@ -117,6 +118,7 @@ impl ConnectorBuilder<WantsSchemes> {
117
118
ConnectorBuilder ( WantsProtocols1 {
118
119
tls_config : self . 0 . tls_config ,
119
120
https_only : false ,
121
+ override_server_name : None ,
120
122
} )
121
123
}
122
124
}
@@ -128,6 +130,7 @@ impl ConnectorBuilder<WantsSchemes> {
128
130
pub struct WantsProtocols1 {
129
131
tls_config : ClientConfig ,
130
132
https_only : bool ,
133
+ override_server_name : Option < String > ,
131
134
}
132
135
133
136
impl WantsProtocols1 {
@@ -136,6 +139,7 @@ impl WantsProtocols1 {
136
139
force_https : self . https_only ,
137
140
http : conn,
138
141
tls_config : std:: sync:: Arc :: new ( self . tls_config ) ,
142
+ override_server_name : self . override_server_name ,
139
143
}
140
144
}
141
145
@@ -169,6 +173,20 @@ impl ConnectorBuilder<WantsProtocols1> {
169
173
enable_http1 : false ,
170
174
} )
171
175
}
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
+ }
172
190
}
173
191
174
192
/// State of a builder with HTTP1 enabled, that may have some other
0 commit comments