MCPcopy Index your code
hub / github.com/coder/coder / loadCertificates

Function loadCertificates

cli/server.go:1696–1717  ·  view source on GitHub ↗
(tlsCertFiles, tlsKeyFiles []string)

Source from the content-addressed store, hash-verified

1694}
1695
1696func 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

Callers 2

configureServerTLSFunction · 0.85
ConfigureHTTPClientFunction · 0.85

Calls 2

NewMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected