You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/07/04 06:34:45 UTC

[GitHub] little-cui commented on a change in pull request #386: SCB-714 Support TLS plugin

little-cui 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_r200020251
 
 

 ##########
 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:
   DONE!

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services