Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kishor Yadav Kommanaboina committed Feb 3, 2025
1 parent 9f89c48 commit 4265aa1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,18 @@ static SSL_CTX *createSSLContext(serverTLSContextConfig *ctx_config, int protoco
return NULL;
}

/* Given a path to a file, return the last time it was accessed (in seconds) */
static time_t getLastModifiedTime(const char* path){
struct stat path_stat;
stat(path, &path_stat);

#ifdef __APPLE__
return path_stat.st_mtimespec.tv_sec;
#else
return path_stat.st_mtime;
#endif
}

/* Attempt to configure/reconfigure TLS. This operation is atomic and will
* leave the SSL_CTX unchanged if fails.
* @priv: config of serverTLSContextConfig.
Expand Down Expand Up @@ -313,6 +325,14 @@ static int tlsConfigure(void *priv, int reconfigure) {
goto error;
}

/* Update the last modified times for the TLS elements */
ctx_config->key_file_last_modified = getLastModifiedTime(ctx_config->key_file);
ctx_config->cert_file_last_modified = getLastModifiedTime(ctx_config->cert_file);
ctx_config->client_cert_file_last_modified = getLastModifiedTime(ctx_config->client_cert_file);
ctx_config->client_key_file_last_modified = getLastModifiedTime(ctx_config->client_key_file);
ctx_config->ca_cert_dir_last_modified = getLastModifiedTime(ctx_config->ca_cert_dir);
ctx_config->ca_cert_file_last_modified = getLastModifiedTime(ctx_config->ca_cert_file);

int protocols = parseProtocolsConfig(ctx_config->protocols);
if (protocols == -1) goto error;

Expand Down

0 comments on commit 4265aa1

Please sign in to comment.