[
https://issues.apache.org/jira/browse/SCB-714?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16532314#comment-16532314
]
ASF GitHub Bot commented on SCB-714:
------------------------------------
tianxiaoliang commented on a change in pull request #386: SCB-714 Support TLS
plugin
URL:
https://github.com/apache/incubator-servicecomb-service-center/pull/386#discussion_r200019255
##########
File path: pkg/rest/client.go
##########
@@ -58,117 +55,26 @@ func NewTransport() *http.Transport {
Dial: NewDialer().Dial,
MaxIdleConnsPerHost: 5,
ResponseHeaderTimeout: DEFAULT_HTTP_RESPONSE_TIMEOUT,
+ TLSHandshakeTimeout: DEFAULT_TLS_HANDSHAKE_TIMEOUT,
}
}
-func getTLSTransport(verifyPeer bool, supplyCert bool, verifyCN bool)
(transport *http.Transport, err error) {
- opts := append(sctls.DefaultClientTLSOptions(),
- tlsutil.WithVerifyPeer(verifyPeer),
- tlsutil.WithVerifyHostName(verifyCN),
- )
-
- if supplyCert {
- _, decrypt := sctls.GetPassphase()
- opts = append(opts,
- tlsutil.WithKeyPass(decrypt),
- )
- } else {
- opts = append(opts,
- tlsutil.WithCert(""),
- tlsutil.WithKey(""),
- )
- }
-
- tlsConfig, err := tlsutil.GetClientTLSConfig(opts...)
- if err != nil {
- return nil, err
- }
-
- transport = NewTransport()
- transport.TLSClientConfig = tlsConfig
- transport.TLSHandshakeTimeout = DEFAULT_TLS_HANDSHAKE_TIMEOUT
- return transport, nil
-}
-
/**
获取普通HTTP客户端
*/
func GetHttpClient(gzip bool) (client *HttpClient, err error) {
return &HttpClient{
gzip: gzip,
- client: &http.Client{
+ Client: &http.Client{
Transport: NewTransport(),
Timeout: DEFAULT_REQUEST_TIMEOUT,
},
}, nil
}
-/**
- 获取匿名认证HTTP客户端(支持压缩, 不校验对端, 不提供证书, 不校验CN)
-*/
-func GetAnonymousHttpsClient(gzip bool) (client *HttpClient, err error) {
- return getHttpsClient(gzip, false, false, false)
-}
-
-/**
- 获取TLS认证HTTP客户端(支持压缩,提供证书,是否认证对端通过参数控制)
-*/
-func GetHttpsClient(gzip, verifyPeer bool) (client *HttpClient, err error) {
- return getHttpsClient(gzip, verifyPeer, true, false)
-}
-
-func getClientByScheme(scheme string) (*HttpClient, error) {
- var err error
- var client *HttpClient
- if scheme == "https" {
- client, err = getHttpsClient(false, false, true, false)
- if err != nil {
- util.Logger().Error("Create https rest.client failed.",
err)
- return nil, err
- }
- return client, nil
- }
- client, err = GetHttpClient(false)
- if err != nil {
- util.Logger().Error("Create http rest.client failed.", err)
- return nil, err
- }
- return client, nil
-}
-
func GetClient(urlPath string) (*HttpClient, error) {
Review comment:
if url is no use delete it
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Support TLS plugin
> ------------------
>
> Key: SCB-714
> URL: https://issues.apache.org/jira/browse/SCB-714
> Project: Apache ServiceComb
> Issue Type: New Feature
> Components: Service-Center
> Reporter: little-cui
> Assignee: little-cui
> Priority: Major
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)