Copilot commented on code in PR #3638:
URL: https://github.com/apache/thrift/pull/3638#discussion_r3594263874


##########
test/rs/src/bin/test_client.rs:
##########
@@ -87,10 +97,18 @@ fn run() -> thrift::Result<()> {
         None => {
             let listen_address = format!("{}:{}", host, port);
             info!(
-                "Client binds to {} with {}+{} stack",
-                listen_address, protocol, transport
+                "Client connects to {} with {}+{}{} stack",
+                listen_address,
+                protocol,
+                transport,
+                if ssl { "+tls" } else { "" }
             );
-            bind(listen_address.as_str(), protocol, transport)?
+            let tls = if ssl {
+                Some((ServerName::try_from(host.to_owned()).unwrap(), 
tls_config()))
+            } else {
+                None
+            };

Review Comment:
   Using `ServerName::try_from(...).unwrap()` will panic on an 
invalid/unsupported `--host` value (e.g., malformed DNS name or IPv6 
formatting), causing the cross-test client to abort instead of returning a 
structured error. Convert the failure into a `thrift::Error` so the harness 
gets a normal failure message.



##########
lib/rs/src/transport/tls.rs:
##########
@@ -0,0 +1,290 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::io::{self, Read, Write};
+use std::net::{Shutdown, TcpStream, ToSocketAddrs};
+use std::ops::{Deref, DerefMut};
+use std::sync::Arc;
+use std::time::Duration;
+
+use rustls::pki_types::ServerName;
+use rustls::{
+    ClientConfig, ClientConnection, ConnectionCommon, ServerConfig, 
ServerConnection, SideData,
+    StreamOwned,
+};
+
+use super::{ReadHalf, TIoChannel, TSharedChannel, WriteHalf};
+use crate::{new_transport_error, TransportErrorKind};
+
+/// A blocking rustls client channel.
+///
+/// The caller supplies a fully configured rustls [`ClientConfig`], including
+/// its crypto provider, trust anchors, client identity, and protocol policy.
+/// The TLS handshake and server-name verification complete before
+/// [`connect`](Self::connect) returns.

Review Comment:
   The doc comment says “server-name verification” completes before `connect` 
returns, but rustls verification behavior is defined by the supplied 
`ClientConfig` (including custom verifiers that may skip name/chain checks). 
Reword to avoid implying Thrift always enforces name verification.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to