forked from TrueCloudLab/frostfs-s3-gw
[#340] Make nats tls and ca params optional
nats.Connect returned error when tls and ca files were not set, what made these params required, but establishing of unsecured connection for debug is acceptable. Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
e0c6544567
commit
4cbce87eac
1 changed files with 7 additions and 2 deletions
|
@ -29,11 +29,16 @@ func NewController(p *Options) (*Controller, error) {
|
|||
}
|
||||
|
||||
ncopts := []nats.Option{
|
||||
nats.ClientCert(p.TLSCertFilepath, p.TLSAuthPrivateKeyFilePath),
|
||||
nats.RootCAs(p.RootCAFiles...),
|
||||
nats.Timeout(p.Timeout),
|
||||
}
|
||||
|
||||
if len(p.TLSCertFilepath) != 0 && len(p.TLSAuthPrivateKeyFilePath) != 0 {
|
||||
ncopts = append(ncopts, nats.ClientCert(p.TLSCertFilepath, p.TLSAuthPrivateKeyFilePath))
|
||||
}
|
||||
if len(p.RootCAFiles) != 0 {
|
||||
ncopts = append(ncopts, nats.RootCAs(p.RootCAFiles...))
|
||||
}
|
||||
|
||||
nc, err := nats.Connect(p.URL, ncopts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue