@@ -779,12 +779,24 @@ parse_long_opt (const char *name, const char *oarg) {
779779 conf .restore = 1 ;
780780
781781 /* TLS/SSL certificate */
782- if (!strcmp ("ssl-cert" , name ))
782+ if (!strcmp ("ssl-cert" , name )) {
783+ // Check if the SSL certificate file exists and is readable
784+ if (access (oarg , F_OK ) != 0 )
785+ FATAL ("SSL certificate file does not exist" );
786+ if (access (oarg , R_OK ) != 0 )
787+ FATAL ("SSL certificate file is not accessible" );
783788 conf .sslcert = oarg ;
789+ }
784790
785791 /* TLS/SSL private key */
786- if (!strcmp ("ssl-key" , name ))
792+ if (!strcmp ("ssl-key" , name )) {
793+ // Check if the SSL private key file exists and is readable
794+ if (access (oarg , F_OK ) != 0 )
795+ FATAL ("SSL key file does not exist" );
796+ if (access (oarg , R_OK ) != 0 )
797+ FATAL ("SSL key file is not accessible" );
787798 conf .sslkey = oarg ;
799+ }
788800
789801 /* timezone */
790802 if (!strcmp ("tz" , name ))
@@ -962,8 +974,15 @@ parse_long_opt (const char *name, const char *oarg) {
962974 }
963975
964976 /* specifies the path of the database file */
965- if (!strcmp ("db-path" , name ))
977+ if (!strcmp ("db-path" , name )) {
978+ struct stat st ;
979+ // Check if the directory exists and is accessible
980+ if (stat (oarg , & st ) != 0 || !S_ISDIR (st .st_mode )) {
981+ perror ("Database path does not exist or is not a directory" );
982+ return -1 ; // Return error or handle as appropriate
983+ }
966984 conf .db_path = oarg ;
985+ }
967986
968987 /* specifies the regex to extract the virtual host */
969988 if (!strcmp ("fname-as-vhost" , name ) && oarg && * oarg != '\0' )
@@ -1186,4 +1205,8 @@ read_option_args (int argc, char **argv) {
11861205 ("--ws-auth-refresh-url requires both --ws-auth with verify and --ws-auth-url to be set." );
11871206 }
11881207 }
1208+ // Ensure that both ssl-cert and ssl-key are either both set or both unset
1209+ if ((conf .sslcert && !conf .sslkey ) || (!conf .sslcert && conf .sslkey )) {
1210+ FATAL ("Both --ssl-cert and --ssl-key must be set and accessible." );
1211+ }
11891212}
0 commit comments