Skip to content

Commit a8856a4

Browse files
committed
Use correct(?) identities
1 parent cab4849 commit a8856a4

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/proxy/outbound.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ impl OutboundConnection {
407407
intended_destination_service: Some(ServiceDescription::from(&*target_service)),
408408
actual_destination,
409409
upstream_sans,
410+
final_sans: vec![],
410411
});
411412
}
412413
// this was service addressed but we did not find a waypoint
@@ -437,6 +438,7 @@ impl OutboundConnection {
437438
intended_destination_service: None,
438439
actual_destination: target,
439440
upstream_sans: vec![],
441+
final_sans: vec![],
440442
});
441443
};
442444

@@ -470,6 +472,7 @@ impl OutboundConnection {
470472
intended_destination_service: us.destination_service.clone(),
471473
actual_destination,
472474
upstream_sans,
475+
final_sans: vec![],
473476
});
474477
}
475478
// Workload doesn't have a waypoint; send directly
@@ -486,9 +489,12 @@ impl OutboundConnection {
486489
Protocol::HBONE | Protocol::DOUBLEHBONE => Some(us.workload_socket_addr()),
487490
Protocol::TCP => None,
488491
};
492+
let (upstream_sans, final_sans) = match us.workload.protocol {
493+
Protocol::DOUBLEHBONE => (vec![us.workload.identity()], us.service_sans()),
494+
Protocol::TCP | Protocol::HBONE => (us.workload_and_services_san(), vec![]),
495+
};
489496

490497
// For case no waypoint for both side and direct to remote node proxy
491-
let upstream_sans = us.workload_and_services_san();
492498
debug!("built request to workload");
493499
Ok(Request {
494500
protocol: us.workload.protocol,
@@ -498,6 +504,7 @@ impl OutboundConnection {
498504
intended_destination_service: us.destination_service.clone(),
499505
actual_destination,
500506
upstream_sans,
507+
final_sans,
501508
})
502509
}
503510
}
@@ -546,6 +553,11 @@ struct Request {
546553
// The identity we will assert for the next hop; this may not be the same as actual_destination_workload
547554
// in the case of proxies along the path.
548555
upstream_sans: Vec<Identity>,
556+
557+
// The identity of workload that will ultimately process this request.
558+
// This field only matters if we need to know both the identity of the next hop, as well as the
559+
// final hop (currently, this is only double HBONE).
560+
final_sans: Vec<Identity>,
549561
}
550562

551563
#[cfg(test)]

src/state.rs

+13
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ impl Upstream {
8888
.chain(std::iter::once(self.workload.identity()))
8989
.collect()
9090
}
91+
92+
pub fn service_sans(&self) -> Vec<Identity> {
93+
self.service_sans
94+
.iter()
95+
.flat_map(|san| match Identity::from_str(san) {
96+
Ok(id) => Some(id),
97+
Err(err) => {
98+
warn!("ignoring invalid SAN {}: {}", san, err);
99+
None
100+
}
101+
})
102+
.collect()
103+
}
91104
}
92105

93106
// Workload information that a specific proxy instance represents. This is used to cross check

0 commit comments

Comments
 (0)