@@ -22,7 +22,6 @@ import (
2222 "crypto/x509"
2323 "errors"
2424 "fmt"
25- "io/ioutil"
2625 "net"
2726 "os"
2827 "strconv"
@@ -33,20 +32,21 @@ import (
3332)
3433
3534type SQCloudConfig struct {
36- Host string
37- Port int
38- Username string
39- Password string
40- Database string
41- Timeout time.Duration
42- CompressMode string
43- Secure bool
44- Pem string
45- ApiKey string
46- NoBlob bool // flag to tell the server to not send BLOB columns
47- MaxData int // value to tell the server to not send columns with more than max_data bytes
48- MaxRows int // value to control rowset chunks based on the number of rows
49- MaxRowset int // value to control the maximum allowed size for a rowset
35+ Host string
36+ Port int
37+ Username string
38+ Password string
39+ Database string
40+ Timeout time.Duration
41+ CompressMode string
42+ Secure bool
43+ TlsInsecureSkipVerify bool
44+ Pem string
45+ ApiKey string
46+ NoBlob bool // flag to tell the server to not send BLOB columns
47+ MaxData int // value to tell the server to not send columns with more than max_data bytes
48+ MaxRows int // value to control rowset chunks based on the number of rows
49+ MaxRowset int // value to control the maximum allowed size for a rowset
5050}
5151
5252type SQCloud struct {
@@ -106,6 +106,7 @@ func ParseConnectionString(ConnectionString string) (config *SQCloudConfig, err
106106 config .Timeout = 0
107107 config .CompressMode = "NO"
108108 config .Secure = true
109+ config .TlsInsecureSkipVerify = false
109110 config .Pem = ""
110111 config .ApiKey = ""
111112 config .NoBlob = false
@@ -133,7 +134,7 @@ func ParseConnectionString(ConnectionString string) (config *SQCloudConfig, err
133134 case "compress" :
134135 config .CompressMode = strings .ToUpper (lastLiteral )
135136 case "tls" :
136- config .Secure , config .Pem = ParseTlsString (lastLiteral )
137+ config .Secure , config .TlsInsecureSkipVerify , config . Pem = ParseTlsString (lastLiteral )
137138 case "apikey" :
138139 config .ApiKey = lastLiteral
139140 case "noblob" :
@@ -161,16 +162,18 @@ func ParseConnectionString(ConnectionString string) (config *SQCloudConfig, err
161162 return nil , err
162163}
163164
164- func ParseTlsString (tlsconf string ) (secure bool , pem string ) {
165+ func ParseTlsString (tlsconf string ) (secure bool , tlsInsecureSkipVerify bool , pem string ) {
165166 switch strings .ToUpper (strings .TrimSpace (tlsconf )) {
166167 case "" , "0" , "N" , "NO" , "FALSE" , "OFF" , "DISABLE" , "DISABLED" :
167- return false , ""
168+ return false , false , ""
168169 case "1" , "Y" , "YES" , "TRUE" , "ON" , "ENABLE" , "ENABLED" :
169- return true , ""
170+ return true , false , ""
171+ case "skip" , "SKIP" :
172+ return true , true , ""
170173 case strings .ToUpper (SQLiteCloudCA ), "INTERN" , "<USE INTERNAL PEM>" :
171- return true , SQLiteCloudCA
174+ return true , false , SQLiteCloudCA
172175 default :
173- return true , strings .TrimSpace (tlsconf )
176+ return true , false , strings .TrimSpace (tlsconf )
174177 }
175178}
176179
@@ -217,7 +220,7 @@ func (this *SQCloud) CheckConnectionParameter() error {
217220 var pool * x509.CertPool = nil
218221 pem := []byte {}
219222
220- switch _ , trimmed := ParseTlsString (this .Pem ); trimmed {
223+ switch _ , _ , trimmed := ParseTlsString (this .Pem ); trimmed {
221224 case "" :
222225 break
223226 case SQLiteCloudCA :
@@ -230,7 +233,7 @@ func (this *SQCloud) CheckConnectionParameter() error {
230233 pem = []byte (trimmed )
231234 } else {
232235 // its a file, read its content into the pem string
233- switch bytes , err := ioutil .ReadFile (trimmed ); {
236+ switch bytes , err := os .ReadFile (trimmed ); {
234237 case err != nil :
235238 return errors .New (fmt .Sprintf ("Could not open PEM file in '%s'" , trimmed ))
236239 default :
@@ -249,7 +252,7 @@ func (this *SQCloud) CheckConnectionParameter() error {
249252
250253 this .cert = & tls.Config {
251254 RootCAs : pool ,
252- InsecureSkipVerify : false ,
255+ InsecureSkipVerify : this . TlsInsecureSkipVerify ,
253256 MinVersion : tls .VersionTLS12 ,
254257 }
255258 }
0 commit comments