(tlsCertFiles, tlsKeyFiles []string)
| 1694 | } |
| 1695 | |
| 1696 | func loadCertificates(tlsCertFiles, tlsKeyFiles []string) ([]tls.Certificate, error) { |
| 1697 | if len(tlsCertFiles) != len(tlsKeyFiles) { |
| 1698 | return nil, xerrors.New("--tls-cert-file and --tls-key-file must be used the same amount of times") |
| 1699 | } |
| 1700 | |
| 1701 | certs := make([]tls.Certificate, len(tlsCertFiles)) |
| 1702 | for i := range tlsCertFiles { |
| 1703 | certFile, keyFile := tlsCertFiles[i], tlsKeyFiles[i] |
| 1704 | cert, err := tls.LoadX509KeyPair(certFile, keyFile) |
| 1705 | if err != nil { |
| 1706 | return nil, xerrors.Errorf( |
| 1707 | "load TLS key pair %d (%q, %q): %w\ncertFiles: %+v\nkeyFiles: %+v", |
| 1708 | i, certFile, keyFile, err, |
| 1709 | tlsCertFiles, tlsKeyFiles, |
| 1710 | ) |
| 1711 | } |
| 1712 | |
| 1713 | certs[i] = cert |
| 1714 | } |
| 1715 | |
| 1716 | return certs, nil |
| 1717 | } |
| 1718 | |
| 1719 | // generateSelfSignedCertificate creates an unsafe self-signed certificate |
| 1720 | // at random that allows users to proceed with setup in the event they |
no test coverage detected