forked from TrueCloudLab/frostfs-api-go
[#286] client: Add TLS options
Add `WithTLSConfig` option to client. If it is not nil then client will try to open secured connection. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
634e405e9c
commit
89aede1fb3
3 changed files with 35 additions and 2 deletions
|
@ -2,6 +2,7 @@ package client
|
|||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/tls"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||
|
@ -110,7 +111,7 @@ func v2MetaHeaderFromOpts(options *callOptions) *v2session.RequestMetaHeader {
|
|||
|
||||
func defaultClientOptions() *clientOptions {
|
||||
return &clientOptions{
|
||||
rawOpts: make([]client.Option, 0, 3),
|
||||
rawOpts: make([]client.Option, 0, 4),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,6 +134,13 @@ func WithDialTimeout(dur time.Duration) Option {
|
|||
}
|
||||
}
|
||||
|
||||
// WithTLSConfig returns option to set connection's TLS config to the remote node.
|
||||
func WithTLSConfig(cfg *tls.Config) Option {
|
||||
return func(opts *clientOptions) {
|
||||
opts.rawOpts = append(opts.rawOpts, client.WithTLSCfg(cfg))
|
||||
}
|
||||
}
|
||||
|
||||
// WithDefaultPrivateKey returns option to set default private key
|
||||
// used for the work.
|
||||
func WithDefaultPrivateKey(key *ecdsa.PrivateKey) Option {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue