Skip to content

Commit

Permalink
tls 1.3 is go 1.12+
Browse files Browse the repository at this point in the history
  • Loading branch information
shueybubbles committed Aug 2, 2022
1 parent 3b46584 commit 5f09ec8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
14 changes: 2 additions & 12 deletions msdsn/conn_str.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,9 @@ func SetupTLS(certificate string, insecureSkipVerify bool, hostInCertificate str
// while SQL Server seems to expect one TCP segment per encrypted TDS package.
// Setting DynamicRecordSizingDisabled to true disables that algorithm and uses 16384 bytes per TLS package
DynamicRecordSizingDisabled: true,
MinVersion: TLSVersionFromString(minTLSVersion),
}
switch minTLSVersion {
case "1.0":
config.MinVersion = tls.VersionTLS10
case "1.1":
config.MinVersion = tls.VersionTLS11
case "1.2":
config.MinVersion = tls.VersionTLS12
case "1.3":
config.MinVersion = tls.VersionTLS13
default:
// use the tls package default
}

if len(certificate) == 0 {
return &config, nil
}
Expand Down
22 changes: 22 additions & 0 deletions msdsn/conn_str_go112.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//go:build go1.12
// +build go1.12

package msdsn

import "crypto/tls"

func TLSVersionFromString(minTLSVersion string) uint16 {
switch minTLSVersion {
case "1.0":
return tls.VersionTLS10
case "1.1":
return tls.VersionTLS11
case "1.2":
return tls.VersionTLS12
case "1.3":
return tls.VersionTLS13
default:
// use the tls package default
}
return 0
}
20 changes: 20 additions & 0 deletions msdsn/conn_str_go112pre.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//go:build !go1.12
// +build !go1.12

package msdsn

import "crypto/tls"

func TLSVersionFromString(minTLSVersion string) uint16 {
switch minTLSVersion {
case "1.0":
return tls.VersionTLS10
case "1.1":
return tls.VersionTLS11
case "1.2":
return tls.VersionTLS12
default:
// use the tls package default
}
return 0
}

0 comments on commit 5f09ec8

Please sign in to comment.