Browse Source

Merge pull request #338 from RealDigitalMedia/update_ssl_debugging

Use InsecureSkipVerify for debug and ServerName for both
Alan Shreve 9 years ago
parent
commit
2b08ceecac
3 changed files with 18 additions and 15 deletions
  1. 2 3
      src/ngrok/client/debug.go
  2. 14 0
      src/ngrok/client/model.go
  3. 2 12
      src/ngrok/client/release.go

+ 2 - 3
src/ngrok/client/debug.go

@@ -6,7 +6,6 @@ var (
 	rootCrtPaths = []string{"assets/client/tls/ngrokroot.crt", "assets/client/tls/snakeoilca.crt"}
 )
 
-// no server name in debug builds so that when you connect it will always work
-func serverName(addr string) string {
-	return ""
+func useInsecureSkipVerify() bool {
+	return true
 }

+ 14 - 0
src/ngrok/client/model.go

@@ -6,6 +6,7 @@ import (
 	metrics "github.com/rcrowley/go-metrics"
 	"io/ioutil"
 	"math"
+	"net"
 	"ngrok/client/mvc"
 	"ngrok/conn"
 	"ngrok/log"
@@ -113,10 +114,23 @@ func newClientModel(config *Configuration, ctl mvc.Controller) *ClientModel {
 
 	// configure TLS SNI
 	m.tlsConfig.ServerName = serverName(m.serverAddr)
+	m.tlsConfig.InsecureSkipVerify = useInsecureSkipVerify()
 
 	return m
 }
 
+// server name in release builds is the host part of the server address
+func serverName(addr string) string {
+	host, _, err := net.SplitHostPort(addr)
+
+	// should never panic because the config parser calls SplitHostPort first
+	if err != nil {
+		panic(err)
+	}
+
+	return host
+}
+
 // mvc.State interface
 func (c ClientModel) GetProtocols() []proto.Protocol { return c.protocols }
 func (c ClientModel) GetClientVersion() string       { return version.MajorMinor() }

+ 2 - 12
src/ngrok/client/release.go

@@ -2,20 +2,10 @@
 
 package client
 
-import "net"
-
 var (
 	rootCrtPaths = []string{"assets/client/tls/ngrokroot.crt"}
 )
 
-// server name in release builds is the host part of the server address
-func serverName(addr string) string {
-	host, _, err := net.SplitHostPort(addr)
-
-	// should never panic because the config parser calls SplitHostPort first
-	if err != nil {
-		panic(err)
-	}
-
-	return host
+func useInsecureSkipVerify() bool {
+	return false
 }