(certFile, keyFile string)
| 42 | } |
| 43 | |
| 44 | func WithCertKeyPairFiles(certFile, keyFile string) TLSConfigOption { |
| 45 | return func(options *TLSConfigOptions) error { |
| 46 | if certFile == "" && keyFile == "" { |
| 47 | return nil |
| 48 | } |
| 49 | |
| 50 | certPEMBlock, err := os.ReadFile(certFile) |
| 51 | if err != nil { |
| 52 | return fmt.Errorf("unable to read cert file: %q: %w", certFile, err) |
| 53 | } |
| 54 | |
| 55 | keyPEMBlock, err := os.ReadFile(keyFile) |
| 56 | if err != nil { |
| 57 | return fmt.Errorf("unable to read key file: %q: %w", keyFile, err) |
| 58 | } |
| 59 | |
| 60 | options.certPEMBlock = certPEMBlock |
| 61 | options.keyPEMBlock = keyPEMBlock |
| 62 | |
| 63 | return nil |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | func WithCAFile(caFile string) TLSConfigOption { |
| 68 | return func(options *TLSConfigOptions) error { |
no outgoing calls
searching dependent graphs…