Snow-kal commented on code in PR #3231:
URL: https://github.com/apache/dubbo-go/pull/3231#discussion_r2901377268


##########
protocol/grpc/client.go:
##########
@@ -127,12 +108,7 @@ func NewClient(url *common.URL) (*Client, error) {
                                logger.Infof("Grpc Client initialized the 
TLSConfig configuration")
                                dialOpts = append(dialOpts, 
grpc.WithTransportCredentials(credentials.NewTLS(cfg)))
                        }
-               } else {
-                       dialOpts = append(dialOpts, 
grpc.WithTransportCredentials(insecure.NewCredentials()))
                }
-       } else {
-               // TODO: remove this else
-               dialOpts = append(dialOpts, 
grpc.WithTransportCredentials(insecure.NewCredentials()))
        }

Review Comment:
   已经更改 感谢建议 这个和以上的 server 的类似
   <img width="1416" height="1055" alt="image" 
src="https://github.com/user-attachments/assets/6bcb347d-5bea-422e-8d3f-11bbef471b2b";
 />
   总结一下就是
   ```
   transportCreds = insecure.NewCredentials()          // 默认值:无 TLS
   if url 有 TLSConfigKey {
       if tlsConf 类型断言失败 {
           return error                                // 配置异常,直接返回
       }
       if IsClientTLSValid(tlsConf) {
           if GetClientTlSConfig 出错 {
               return error                            // 获取 TLS 配置失败,直接返回
           }
           if cfg != nil {
               transportCreds = credentials.NewTLS(cfg) // 覆盖为 TLS
           }
       }
   }
   dialOpts = append(dialOpts, grpc.WithTransportCredentials(transportCreds))  
// 只 append 一次
   ```



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to