@@ -47,26 +47,24 @@ pub struct TlsCertAndKey {
4747}
4848
4949/// Inner struct used by [ProxyClient] and [ProxyServer]
50- struct Proxy < L , R >
50+ struct Proxy < R >
5151where
52- L : QuoteGenerator ,
5352 R : QuoteVerifier ,
5453{
5554 /// The underlying TCP listener
5655 listener : TcpListener ,
5756 /// Quote generation type to use (including none)
58- local_quote_generator : L ,
57+ local_quote_generator : Arc < dyn QuoteGenerator > ,
5958 /// Verifier for remote attestation (including none)
6059 remote_quote_verifier : R ,
6160}
6261
6362/// A TLS over TCP server which provides an attestation before forwarding traffic to a given target address
64- pub struct ProxyServer < L , R >
63+ pub struct ProxyServer < R >
6564where
66- L : QuoteGenerator ,
6765 R : QuoteVerifier ,
6866{
69- inner : Proxy < L , R > ,
67+ inner : Proxy < R > ,
7068 /// The certificate chain
7169 cert_chain : Vec < CertificateDer < ' static > > ,
7270 /// For accepting TLS connections
@@ -75,12 +73,12 @@ where
7573 target : SocketAddr ,
7674}
7775
78- impl < L : QuoteGenerator , R : QuoteVerifier > ProxyServer < L , R > {
76+ impl < R : QuoteVerifier > ProxyServer < R > {
7977 pub async fn new (
8078 cert_and_key : TlsCertAndKey ,
8179 local : impl ToSocketAddrs ,
8280 target : SocketAddr ,
83- local_quote_generator : L ,
81+ local_quote_generator : Arc < dyn QuoteGenerator > ,
8482 remote_quote_verifier : R ,
8583 client_auth : bool ,
8684 ) -> Result < Self , ProxyError > {
@@ -121,7 +119,7 @@ impl<L: QuoteGenerator, R: QuoteVerifier> ProxyServer<L, R> {
121119 server_config : Arc < ServerConfig > ,
122120 local : impl ToSocketAddrs ,
123121 target : SocketAddr ,
124- local_quote_generator : L ,
122+ local_quote_generator : Arc < dyn QuoteGenerator > ,
125123 remote_quote_verifier : R ,
126124 ) -> Result < Self , ProxyError > {
127125 let acceptor = tokio_rustls:: TlsAcceptor :: from ( server_config) ;
@@ -177,7 +175,7 @@ impl<L: QuoteGenerator, R: QuoteVerifier> ProxyServer<L, R> {
177175 acceptor : TlsAcceptor ,
178176 target : SocketAddr ,
179177 cert_chain : Vec < CertificateDer < ' static > > ,
180- local_quote_generator : L ,
178+ local_quote_generator : Arc < dyn QuoteGenerator > ,
181179 remote_quote_verifier : R ,
182180 ) -> Result < ( ) , ProxyError > {
183181 let mut tls_stream = acceptor. accept ( inbound) . await ?;
@@ -303,25 +301,24 @@ fn full<T: Into<Bytes>>(chunk: T) -> BoxBody<Bytes, hyper::Error> {
303301 . boxed ( )
304302}
305303
306- pub struct ProxyClient < L , R >
304+ pub struct ProxyClient < R >
307305where
308- L : QuoteGenerator ,
309306 R : QuoteVerifier ,
310307{
311- inner : Proxy < L , R > ,
308+ inner : Proxy < R > ,
312309 connector : TlsConnector ,
313310 /// The host and port of the proxy server
314311 target : String ,
315312 /// Certificate chain for client auth
316313 cert_chain : Option < Vec < CertificateDer < ' static > > > ,
317314}
318315
319- impl < L : QuoteGenerator , R : QuoteVerifier > ProxyClient < L , R > {
316+ impl < R : QuoteVerifier > ProxyClient < R > {
320317 pub async fn new (
321318 cert_and_key : Option < TlsCertAndKey > ,
322319 address : impl ToSocketAddrs ,
323320 server_name : String ,
324- local_quote_generator : L ,
321+ local_quote_generator : Arc < dyn QuoteGenerator > ,
325322 remote_quote_verifier : R ,
326323 ) -> Result < Self , ProxyError > {
327324 if local_quote_generator. attestation_type ( ) != AttestationType :: None
@@ -363,7 +360,7 @@ impl<L: QuoteGenerator, R: QuoteVerifier> ProxyClient<L, R> {
363360 client_config : Arc < ClientConfig > ,
364361 local : impl ToSocketAddrs ,
365362 target_name : String ,
366- local_quote_generator : L ,
363+ local_quote_generator : Arc < dyn QuoteGenerator > ,
367364 remote_quote_verifier : R ,
368365 cert_chain : Option < Vec < CertificateDer < ' static > > > ,
369366 ) -> Result < Self , ProxyError > {
@@ -423,7 +420,7 @@ impl<L: QuoteGenerator, R: QuoteVerifier> ProxyClient<L, R> {
423420 connector : TlsConnector ,
424421 target : String ,
425422 cert_chain : Option < Vec < CertificateDer < ' static > > > ,
426- local_quote_generator : L ,
423+ local_quote_generator : Arc < dyn QuoteGenerator > ,
427424 remote_quote_verifier : R ,
428425 ) -> Result < ( ) , ProxyError > {
429426 let http = Builder :: new ( ) ;
@@ -467,7 +464,7 @@ impl<L: QuoteGenerator, R: QuoteVerifier> ProxyClient<L, R> {
467464 connector : TlsConnector ,
468465 target : String ,
469466 cert_chain : Option < Vec < CertificateDer < ' static > > > ,
470- local_quote_generator : L ,
467+ local_quote_generator : Arc < dyn QuoteGenerator > ,
471468 remote_quote_verifier : R ,
472469 ) -> Result <
473470 (
@@ -528,7 +525,7 @@ impl<L: QuoteGenerator, R: QuoteVerifier> ProxyClient<L, R> {
528525 connector : TlsConnector ,
529526 target : String ,
530527 cert_chain : Option < Vec < CertificateDer < ' static > > > ,
531- local_quote_generator : L ,
528+ local_quote_generator : Arc < dyn QuoteGenerator > ,
532529 remote_quote_verifier : R ,
533530 ) -> Result < Response < BoxBody < bytes:: Bytes , hyper:: Error > > , ProxyError > {
534531 let remote_attestation_type = remote_quote_verifier. attestation_type ( ) ;
@@ -710,9 +707,9 @@ mod tests {
710707 server_config,
711708 "127.0.0.1:0" ,
712709 target_addr,
713- DcapTdxQuoteGenerator {
710+ Arc :: new ( DcapTdxQuoteGenerator {
714711 attestation_type : AttestationType :: Dummy ,
715- } ,
712+ } ) ,
716713 NoQuoteVerifier ,
717714 )
718715 . await
@@ -739,7 +736,7 @@ mod tests {
739736 client_config,
740737 "127.0.0.1:0" . to_string ( ) ,
741738 proxy_addr. to_string ( ) ,
742- NoQuoteGenerator ,
739+ Arc :: new ( NoQuoteGenerator ) ,
743740 quote_verifier,
744741 None ,
745742 )
@@ -807,9 +804,9 @@ mod tests {
807804 server_tls_server_config,
808805 "127.0.0.1:0" ,
809806 target_addr,
810- DcapTdxQuoteGenerator {
807+ Arc :: new ( DcapTdxQuoteGenerator {
811808 attestation_type : AttestationType :: Dummy ,
812- } ,
809+ } ) ,
813810 quote_verifier. clone ( ) ,
814811 )
815812 . await
@@ -825,9 +822,9 @@ mod tests {
825822 client_tls_client_config,
826823 "127.0.0.1:0" ,
827824 proxy_addr. to_string ( ) ,
828- DcapTdxQuoteGenerator {
825+ Arc :: new ( DcapTdxQuoteGenerator {
829826 attestation_type : AttestationType :: Dummy ,
830- } ,
827+ } ) ,
831828 quote_verifier,
832829 Some ( client_cert_chain) ,
833830 )
@@ -876,9 +873,9 @@ mod tests {
876873 server_config,
877874 "127.0.0.1:0" ,
878875 target_addr,
879- DcapTdxQuoteGenerator {
876+ Arc :: new ( DcapTdxQuoteGenerator {
880877 attestation_type : AttestationType :: Dummy ,
881- } ,
878+ } ) ,
882879 NoQuoteVerifier ,
883880 )
884881 . await
0 commit comments