File tree 2 files changed +17
-0
lines changed 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ docker run -d -p 3000:3000 \
21
21
22
22
* Authentication:
23
23
* HTTP Basic
24
+ * TLS client authentication
24
25
* Raw SQL editor only, no query builder yet
25
26
* Macros
26
27
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package driver
3
3
import (
4
4
"crypto/tls"
5
5
"database/sql"
6
+ "errors"
7
+ "fmt"
6
8
"net/http"
7
9
8
10
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
@@ -17,14 +19,28 @@ const DriverName string = "trino"
17
19
func Open (settings models.TrinoDatasourceSettings ) (* sql.DB , error ) {
18
20
skipVerify := false
19
21
sslCert := ""
22
+ var clientCert []tls.Certificate
20
23
if settings .Opts .TLS != nil {
21
24
skipVerify = settings .Opts .TLS .InsecureSkipVerify
22
25
sslCert = settings .Opts .TLS .CACertificate
23
26
}
27
+ if settings .Opts .TLS .ClientCertificate != "" {
28
+ if settings .Opts .TLS .ClientKey == "" {
29
+ return nil , errors .New ("client certificate was configured without a client key" )
30
+ }
31
+ cert , err := tls .X509KeyPair (
32
+ []byte (settings .Opts .TLS .ClientCertificate ),
33
+ []byte (settings .Opts .TLS .ClientKey ))
34
+ if err != nil {
35
+ return nil , fmt .Errorf ("failed to load client certificate: %w" , err )
36
+ }
37
+ clientCert = append (clientCert , cert )
38
+ }
24
39
client := & http.Client {
25
40
Transport : & http.Transport {
26
41
TLSClientConfig : & tls.Config {
27
42
InsecureSkipVerify : skipVerify ,
43
+ Certificates : clientCert ,
28
44
},
29
45
},
30
46
}
You can’t perform that action at this time.
0 commit comments