Browse code

tls: try to lookup client profile via bind address

- local address connection can have a randomly allocated port by os

Daniel-Constantin Mierla authored on 23/02/2015 22:27:48
Showing 1 changed files
... ...
@@ -196,8 +196,16 @@ static int tls_complete_init(struct tcp_connection* c)
196 196
 	} else {
197 197
 		state=S_TLS_CONNECTING;
198 198
 		sname = tls_get_connect_server_name();
199
-		dom = tls_lookup_cfg(cfg, TLS_DOMAIN_CLI,
200
-								&c->rcv.dst_ip, c->rcv.dst_port, sname);
199
+		if(&c->rcv.bind_address!=NULL) {
200
+			/* if there is a bind_address, use it, because the src port
201
+			 * for connection can be randomly assigned by OS */
202
+			dom = tls_lookup_cfg(cfg, TLS_DOMAIN_CLI,
203
+						&c->rcv.bind_address->address,
204
+						c->rcv.bind_address->port_no, sname);
205
+		} else {
206
+			dom = tls_lookup_cfg(cfg, TLS_DOMAIN_CLI,
207
+						&c->rcv.dst_ip, c->rcv.dst_port, sname);
208
+		}
201 209
 	}
202 210
 	if (unlikely(c->state<0)) {
203 211
 		BUG("Invalid connection (state %d)\n", c->state);