()
| 33 | } |
| 34 | |
| 35 | func (this *TLSConfig) BuildConfig() (*tls.Config, error) { |
| 36 | if this.tlsConfig == nil { |
| 37 | certPool := x509.NewCertPool() |
| 38 | pem, err := ioutil.ReadFile(this.CertPath) |
| 39 | if err != nil { |
| 40 | return nil, err |
| 41 | } |
| 42 | |
| 43 | if ok := certPool.AppendCertsFromPEM(pem); !ok { |
| 44 | return nil, errors.New("unable to append pem") |
| 45 | } |
| 46 | |
| 47 | this.tlsConfig = &tls.Config{ |
| 48 | RootCAs: certPool, |
| 49 | ServerName: this.ServerName, |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return this.tlsConfig, nil |
| 54 | } |
| 55 | |
| 56 | type DatabaseConfig struct { |
| 57 | Host string |
no outgoing calls