MCPcopy Create free account
hub / github.com/ddev/ddev / getCertificateForPrivateKey

Function getCertificateForPrivateKey

cmd/ddev/cmd/auth-ssh.go:171–187  ·  view source on GitHub ↗

getCertificateForPrivateKey returns path and name for optional OpenSSH certificate https://www.man7.org/linux/man-pages/man1/ssh-keygen.1.html#CERTIFICATES https://github.com/ddev/ddev/issues/6832

(path string, name string)

Source from the content-addressed store, hash-verified

169// https://www.man7.org/linux/man-pages/man1/ssh-keygen.1.html#CERTIFICATES
170// https://github.com/ddev/ddev/issues/6832
171func getCertificateForPrivateKey(path string, name string) (string, string) {
172 cert := path + "-cert.pub"
173 if !fileutil.FileExists(cert) {
174 return "", ""
175 }
176 certPath, err := filepath.EvalSymlinks(cert)
177 if err != nil {
178 util.Warning("Unable to read %s file: %v", cert, err)
179 return "", ""
180 }
181 if !fileutil.FileIsReadable(certPath) {
182 util.Warning("Unable to read %s file: file is not readable", certPath)
183 return "", ""
184 }
185 certName := name + "-cert.pub"
186 return certPath, certName
187}
188
189// GetAuthSSHCmd wraps the command to be run inside the SSH auth container.
190// SSH auth container mounts the SSH keys into /tmp/sshtmp location,

Callers 1

runSSHAuthContainerFunction · 0.85

Calls 3

FileExistsFunction · 0.92
WarningFunction · 0.92
FileIsReadableFunction · 0.92

Tested by

no test coverage detected