@@ -50,8 +50,27 @@ impl TlsConnection for BoringSslConnection {
5050 config : & Self :: Config ,
5151 io : & Rc < harness:: TestPairIO > ,
5252 ) -> Result < Self , Box < dyn Error > > {
53- // No tickets/resumption yet: keep it simple
54- let ssl = Ssl :: new ( & config. config ) ?;
53+ // Check if there is a session ticket available.
54+ // A session ticket will only be available if the Config was created
55+ // with session resumption enabled (and a previous handshake stored it).
56+ let maybe_ticket = config
57+ . session_ticket_storage
58+ . stored_ticket
59+ . lock ( )
60+ . unwrap ( )
61+ . take ( ) ;
62+
63+ // Populate the internal session cache (mirrors the OpenSSL harness pattern).
64+ if let Some ( ticket) = & maybe_ticket {
65+ let _ = unsafe { config. config . add_session ( ticket) } ;
66+ }
67+
68+ let mut ssl = Ssl :: new ( & config. config ) ?;
69+
70+ // If we have a ticket, attempt to resume with it.
71+ if let Some ( ticket) = & maybe_ticket {
72+ unsafe { ssl. set_session ( ticket) ? } ;
73+ }
5574
5675 let view = match mode {
5776 Mode :: Client => io. client_view ( ) ,
@@ -65,7 +84,7 @@ impl TlsConnection for BoringSslConnection {
6584 } )
6685 }
6786
68- fn handshake ( & mut self ) -> Result < ( ) , Box < dyn std :: error :: Error > > {
87+ fn handshake ( & mut self ) -> Result < ( ) , Box < dyn Error > > {
6988 // If the handshake is already complete, no further work is needed.
7089 if self . connection . ssl ( ) . is_init_finished ( ) {
7190 return Ok ( ( ) ) ;
@@ -96,18 +115,15 @@ impl TlsConnection for BoringSslConnection {
96115 fn send ( & mut self , data : & [ u8 ] ) {
97116 let mut write_offset = 0 ;
98117 while write_offset < data. len ( ) {
99- write_offset += self
100- . connection
101- . write ( & data[ write_offset..data. len ( ) ] )
102- . unwrap ( ) ;
118+ write_offset += self . connection . write ( & data[ write_offset..] ) . unwrap ( ) ;
103119 self . connection . flush ( ) . unwrap ( ) ; // make sure internal buffers don't fill up
104120 }
105121 }
106122
107123 fn recv ( & mut self , data : & mut [ u8 ] ) -> std:: io:: Result < ( ) > {
108124 let data_len = data. len ( ) ;
109125 let mut read_offset = 0 ;
110- while read_offset < data . len ( ) {
126+ while read_offset < data_len {
111127 read_offset += self . connection . read ( & mut data[ read_offset..data_len] ) ?
112128 }
113129 Ok ( ( ) )
@@ -125,19 +141,16 @@ impl TlsConnection for BoringSslConnection {
125141
126142impl TlsInfo for BoringSslConnection {
127143 fn name ( ) -> String {
128- // BoringSSL doesn't expose a version number in the same way as OpenSSL
129- // It's typically identified just as "boringssl"
130144 "boringssl" . to_string ( )
131145 }
132146
133147 fn get_negotiated_cipher_suite ( & self ) -> String {
134- let cipher_suite = self
135- . connection
148+ self . connection
136149 . ssl ( )
137150 . current_cipher ( )
138151 . expect ( "Handshake not completed" )
139- . name ( ) ;
140- cipher_suite . to_string ( )
152+ . name ( )
153+ . to_string ( )
141154 }
142155
143156 fn negotiated_tls13 ( & self ) -> bool {
@@ -155,6 +168,7 @@ impl TlsInfo for BoringSslConnection {
155168 fn mutual_auth ( & self ) -> bool {
156169 assert ! ( self . connection. ssl( ) . is_server( ) ) ;
157170 self . connection . ssl ( ) . peer_certificate ( ) . is_some ( )
171+ && self . connection . ssl ( ) . verify_result ( ) . is_ok ( )
158172 }
159173}
160174
0 commit comments