Merge pull request #2 from erikwilson/user-config-ca-cert-key

Use CA cert & key from user tls config
This commit is contained in:
Darren Shepherd 2019-07-02 14:23:29 -07:00 committed by GitHub
commit 4716ac2362
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 5 deletions

View File

@ -424,12 +424,25 @@ func (s *server) getCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, e
changed = true
if s.activeCA == nil {
ca, key, err := genCA()
if err != nil {
return nil, err
if s.userConfig.CACerts != "" && s.userConfig.CAKey != "" {
ca, err := cert.ParseCertsPEM([]byte(s.userConfig.CACerts))
if err != nil {
return nil, err
}
key, err := cert.ParsePrivateKeyPEM([]byte(s.userConfig.CAKey))
if err != nil {
return nil, err
}
s.activeCA = ca[0]
s.activeCAKey = key.(crypto.Signer)
} else {
ca, key, err := genCA()
if err != nil {
return nil, err
}
s.activeCA = ca
s.activeCAKey = key
}
s.activeCA = ca
s.activeCAKey = key
}
cfg := cert.Config{

View File

@ -29,6 +29,7 @@ type UserConfig struct {
Mode string
NoCACerts bool
CACerts string
CAKey string
Cert string
Key string
BindAddress string