Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
73e40597
Commit
73e40597
authored
May 16, 2019
by
Tom Petr
Committed by
Carl Bergquist
May 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for periodically reloading mysql client certs (#14892)
parent
3dbc3251
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
pkg/services/sqlstore/sqlstore.go
+1
-1
pkg/services/sqlstore/tls_mysql.go
+13
-11
No files found.
pkg/services/sqlstore/sqlstore.go
View file @
73e40597
...
...
@@ -171,7 +171,7 @@ func (ss *SqlStore) buildConnectionString() (string, error) {
ss
.
dbCfg
.
User
,
ss
.
dbCfg
.
Pwd
,
protocol
,
ss
.
dbCfg
.
Host
,
ss
.
dbCfg
.
Name
)
if
ss
.
dbCfg
.
SslMode
==
"true"
||
ss
.
dbCfg
.
SslMode
==
"skip-verify"
{
tlsCert
,
err
:=
makeCert
(
"custom"
,
ss
.
dbCfg
)
tlsCert
,
err
:=
makeCert
(
ss
.
dbCfg
)
if
err
!=
nil
{
return
""
,
err
}
...
...
pkg/services/sqlstore/tls_mysql.go
View file @
73e40597
...
...
@@ -5,9 +5,13 @@ import (
"crypto/x509"
"fmt"
"io/ioutil"
"github.com/grafana/grafana/pkg/infra/log"
)
func
makeCert
(
tlsPoolName
string
,
config
DatabaseConfig
)
(
*
tls
.
Config
,
error
)
{
var
tlslog
=
log
.
New
(
"tls_mysql"
)
func
makeCert
(
config
DatabaseConfig
)
(
*
tls
.
Config
,
error
)
{
rootCertPool
:=
x509
.
NewCertPool
()
pem
,
err
:=
ioutil
.
ReadFile
(
config
.
CaCertPath
)
if
err
!=
nil
{
...
...
@@ -16,18 +20,16 @@ func makeCert(tlsPoolName string, config DatabaseConfig) (*tls.Config, error) {
if
ok
:=
rootCertPool
.
AppendCertsFromPEM
(
pem
);
!
ok
{
return
nil
,
err
}
clientCert
:=
make
([]
tls
.
Certificate
,
0
,
1
)
if
config
.
ClientCertPath
!=
""
&&
config
.
ClientKeyPath
!=
""
{
certs
,
err
:=
tls
.
LoadX509KeyPair
(
config
.
ClientCertPath
,
config
.
ClientKeyPath
)
if
err
!=
nil
{
return
nil
,
err
}
clientCert
=
append
(
clientCert
,
certs
)
}
tlsConfig
:=
&
tls
.
Config
{
RootCAs
:
rootCertPool
,
Certificates
:
clientCert
,
RootCAs
:
rootCertPool
,
}
if
config
.
ClientCertPath
!=
""
&&
config
.
ClientKeyPath
!=
""
{
tlsConfig
.
GetClientCertificate
=
func
(
*
tls
.
CertificateRequestInfo
)
(
*
tls
.
Certificate
,
error
)
{
tlslog
.
Debug
(
"Loading client certificate"
)
cert
,
err
:=
tls
.
LoadX509KeyPair
(
config
.
ClientCertPath
,
config
.
ClientKeyPath
)
return
&
cert
,
err
}
}
tlsConfig
.
ServerName
=
config
.
ServerCertName
if
config
.
SslMode
==
"skip-verify"
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment