Просмотр исходного кода

Report negotiated TLS versions

Rod Hynes 6 лет назад
Родитель
Сommit
e8737ac1b7
1 измененных файлов с 19 добавлено и 1 удалено
  1. 19 1
      psiphon/tlsDialer_test.go

+ 19 - 1
psiphon/tlsDialer_test.go

@@ -134,6 +134,7 @@ func testTLSDialerCompatibility(t *testing.T, address string) {
 		}
 		}
 
 
 		success := 0
 		success := 0
+		tlsVersions := []string{}
 		for i := 0; i < repeats; i++ {
 		for i := 0; i < repeats; i++ {
 
 
 			tlsConfig := &CustomTLSConfig{
 			tlsConfig := &CustomTLSConfig{
@@ -151,6 +152,20 @@ func testTLSDialerCompatibility(t *testing.T, address string) {
 			if err != nil {
 			if err != nil {
 				t.Logf("%s: %s\n", tlsProfile, err)
 				t.Logf("%s: %s\n", tlsProfile, err)
 			} else {
 			} else {
+
+				tlsVersion := ""
+				version := conn.(*utls.UConn).ConnectionState().Version
+				if version == utls.VersionTLS12 {
+					tlsVersion = "TLS 1.2"
+				} else if version == utls.VersionTLS13 {
+					tlsVersion = "TLS 1.3"
+				} else {
+					t.Fatalf("Unexpected TLS version: %v", version)
+				}
+				if !common.Contains(tlsVersions, tlsVersion) {
+					tlsVersions = append(tlsVersions, tlsVersion)
+				}
+
 				conn.Close()
 				conn.Close()
 				success += 1
 				success += 1
 			}
 			}
@@ -160,7 +175,10 @@ func testTLSDialerCompatibility(t *testing.T, address string) {
 			time.Sleep(100 * time.Millisecond)
 			time.Sleep(100 * time.Millisecond)
 		}
 		}
 
 
-		result := fmt.Sprintf("%s: %d/%d successful\n", tlsProfile, success, repeats)
+		result := fmt.Sprintf(
+			"%s: %d/%d successful; negotiated TLS versions: %v\n",
+			tlsProfile, success, repeats, tlsVersions)
+
 		if success == repeats {
 		if success == repeats {
 			t.Logf(result)
 			t.Logf(result)
 		} else {
 		} else {