copyTLSFiles clones certs files to dst directory.
(ti transport.TLSInfo, dst string)
| 24 | |
| 25 | // copyTLSFiles clones certs files to dst directory. |
| 26 | func copyTLSFiles(ti transport.TLSInfo, dst string) (transport.TLSInfo, error) { |
| 27 | ci := transport.TLSInfo{ |
| 28 | KeyFile: filepath.Join(dst, "server-key.pem"), |
| 29 | CertFile: filepath.Join(dst, "server.pem"), |
| 30 | TrustedCAFile: filepath.Join(dst, "etcd-root-ca.pem"), |
| 31 | ClientCertAuth: ti.ClientCertAuth, |
| 32 | } |
| 33 | if err := copyFile(ti.KeyFile, ci.KeyFile); err != nil { |
| 34 | return transport.TLSInfo{}, err |
| 35 | } |
| 36 | if err := copyFile(ti.CertFile, ci.CertFile); err != nil { |
| 37 | return transport.TLSInfo{}, err |
| 38 | } |
| 39 | if err := copyFile(ti.TrustedCAFile, ci.TrustedCAFile); err != nil { |
| 40 | return transport.TLSInfo{}, err |
| 41 | } |
| 42 | return ci, nil |
| 43 | } |
| 44 | |
| 45 | func copyFile(src, dst string) error { |
| 46 | f, err := os.Open(src) |
no test coverage detected
searching dependent graphs…