writeTmpKeyFile writes key content to a temporary file and returns the name of that file, along with any possible errors.
(content, keyTestPath string)
| 176 | // writeTmpKeyFile writes key content to a temporary file |
| 177 | // and returns the name of that file, along with any possible errors. |
| 178 | func writeTmpKeyFile(content, keyTestPath string) (string, error) { |
| 179 | tmpFile, err := os.CreateTemp(keyTestPath, "gogs_keytest") |
| 180 | if err != nil { |
| 181 | return "", errors.Newf("TempFile: %v", err) |
| 182 | } |
| 183 | defer tmpFile.Close() |
| 184 | |
| 185 | if _, err = tmpFile.WriteString(content); err != nil { |
| 186 | return "", errors.Newf("WriteString: %v", err) |
| 187 | } |
| 188 | return tmpFile.Name(), nil |
| 189 | } |
| 190 | |
| 191 | // SSHKeygenParsePublicKey extracts key type and length using ssh-keygen. |
| 192 | func SSHKeygenParsePublicKey(key, keyTestPath, keygenPath string) (string, int, error) { |
no test coverage detected