NewTLSConfigForContext creates a tls.Config from the given options and stores it in the returned context.
(ctx context.Context, opts TLSConfigOptions)
| 114 | // NewTLSConfigForContext creates a tls.Config from the given options and stores it |
| 115 | // in the returned context. |
| 116 | func NewTLSConfigForContext(ctx context.Context, opts TLSConfigOptions) (context.Context, error) { |
| 117 | conf, err := newTLSConfigFromSecret(ctx, opts) |
| 118 | if err != nil { |
| 119 | return ctx, err |
| 120 | } |
| 121 | |
| 122 | if opts.ClientCert != nil { |
| 123 | conf.Certificates = []tls.Certificate{*opts.ClientCert} |
| 124 | } |
| 125 | |
| 126 | return context.WithValue(ctx, contextKeyTLSConfig, conf), nil |
| 127 | } |
| 128 | |
| 129 | // GetTLSConfigFromContext returns the *tls.Config contained by the context or any error encountered |
| 130 | func GetTLSConfigFromContext(ctx context.Context) (*tls.Config, error) { |
no test coverage detected