- /* Hostname too long. */
- if (size - strlen(STORED_SERVER_CERT_FORMAT) <= strlen(hostname)) {
- LOG(LOG_WARNING,
- "server_certificate_path(): hostname too long: '%s'",
- hostname);
- return -1;
- }
- /* Try to prevent path traversals in hostnames. */
- if (NULL != strstr(hostname, "..")) {
- LOG(LOG_WARNING,
- "server_certificate_path(): possible path traversal: '%s'",
- hostname);
- return -1;
- }
- result = snprintf(path, size, STORED_SERVER_CERT_FORMAT, hostname);
- if (result < 0) {
+int server_certificate_file(FILE **file, const char *hostname,
+ char *path, size_t size) {
+ if (get_certificate_path(STORED_SERVER_CERT_FORMAT,
+ hostname, path, size) != 0) {