Skip to content

Commit 39e8644

Browse files
committed
We're skipping TLS verification! Bug in Mac OS for Golang, golang/go#24652 (comment). Also, andygrunwald/go-jira#52.
1 parent 0f33788 commit 39e8644

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

cmd/root.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package cmd
1616

1717
import (
18+
"crypto/tls"
1819
"fmt"
1920
"net/http"
2021
"net/url"
@@ -105,7 +106,7 @@ func init() {
105106
// will be global for your application.
106107
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file path (default is $HOME/.nethelp.yaml)")
107108
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "print all logging levels")
108-
rootCmd.PersistentFlags().StringVarP(&userProxy, "proxy", "p", "", "upstream proxy for nethelp to use. Port should be added like my.proxy:8080")
109+
rootCmd.PersistentFlags().StringVarP(&userProxy, "proxy", "p", "", "upstream proxy for nethelp to use. Enter like -p protocol://username:password@host:port")
109110
// TODO
110111
// root.rootCmd.PersistentFlags().StringVarP(&proxyAuth, "auth", "a", "", "authentication for upstream proxy. use like -a username:password.")
111112

@@ -172,7 +173,7 @@ func addProxy(rawProxy string, cmd *cobra.Command) *url.URL {
172173
log.Fatalf("Panic while setting proxy %s. Proxy not set and program exiting. %v", rawProxy, err)
173174
}
174175
// This takes care of HTTP calls globally
175-
http.DefaultTransport = &http.Transport{Proxy: http.ProxyURL(proxyURL)}
176+
http.DefaultTransport = &http.Transport{Proxy: http.ProxyURL(proxyURL), TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
176177
}
177178
// check that there are no env vars defining a proxy and everything works
178179
if disableCheck != true {
@@ -188,14 +189,20 @@ func checkProxy(rawProxy string) {
188189
log.WithFields(log.Fields{
189190
"error": err,
190191
"msg": "www.saucelabs.com not reachable with this proxy",
191-
}).Fatalf("Something is wrong with the proxy %s. It cannot be used.", rawProxy)
192+
}).Fatalf("Something is wrong with the user specified proxy %s. It cannot be used.", rawProxy)
192193
} else {
193194
log.WithFields(log.Fields{
194195
"error": err,
195196
"msg": "www.saucelabs.com not reachable with this proxy",
197+
"resp": *resp,
196198
}).Fatal("Something is wrong with the proxy specified in your environment variables. It cannot be used.")
197199
}
198200
}
201+
if resp.StatusCode != 200 {
202+
log.WithFields(log.Fields{
203+
"response": *resp,
204+
}).Fatal("Something is wrong with the proxy. It cannot was not able to reach a public website.")
205+
}
199206
log.Info("Proxy OK. Able to reach www.saucelabs.com.", resp)
200207
}
201208

@@ -208,7 +215,6 @@ func runDefault(cmd *cobra.Command) bool {
208215
if err != nil {
209216
log.Fatal("Could not get the TCP flag. ", err)
210217
}
211-
log.Debug("Checking commands to see if we don't want to run default test set. ", runHTTP, runTCP)
212218
if runHTTP || runTCP {
213219
log.Debug("HTTP or TCP flag used. Not running default test set.", runHTTP, runTCP)
214220
return false
@@ -224,7 +230,6 @@ func assembleVDCEndpoints() []string {
224230
vdcRESTEndpoints := []string{""}
225231
endpoint := fmt.Sprintf("https://saucelabs.com/rest/v1/%s/tunnels", os.Getenv("SAUCE_USERNAME"))
226232
vdcRESTEndpoints[0] = endpoint
227-
fmt.Println(vdcRESTEndpoints[0])
228233
return vdcRESTEndpoints
229234
}
230235

0 commit comments

Comments
 (0)