diff --git a/winpr/tools/makecert-cli/winpr-makecert.1.in b/winpr/tools/makecert-cli/winpr-makecert.1.in index a50c82c49..a1eb841b7 100644 --- a/winpr/tools/makecert-cli/winpr-makecert.1.in +++ b/winpr/tools/makecert-cli/winpr-makecert.1.in @@ -72,10 +72,10 @@ can be thought as "dummy" mode. .IP "-n common_name" The common name to use in the certificate. .IP "-m months" -Validity period in months. +Validity period in months (multiple of 31 days, not clanendar months). .IP "-y years" -Validity period in years. If months and years are specified the specified -month parameter will take precedence. +Validity period in years (365 days, leap years not accounted). If months and years are specified the specified +the values are accumulated. .IP "-len length" Key length in bits to use. .IP "-a { \fImd5\fP | \fIsha1\fP | \fIsha256\fP | \fIs384\fP | \fIsha512\fP }" diff --git a/winpr/tools/makecert/makecert.c b/winpr/tools/makecert/makecert.c index 85baeef95..0929c1d56 100644 --- a/winpr/tools/makecert/makecert.c +++ b/winpr/tools/makecert/makecert.c @@ -405,7 +405,7 @@ static int makecert_context_parse_arguments(MAKECERT_CONTEXT* context, val = strtol(arg->Value, NULL, 0); - if ((errno != 0) || (val < 1) || (val > 12)) + if ((errno != 0) || (val < 0)) return -1; context->duration_months = (int)val; @@ -999,10 +999,9 @@ int makecert_context_process(MAKECERT_CONTEXT* context, int argc, char** argv) #endif X509_gmtime_adj(before, 0); - if (context->duration_months) - X509_gmtime_adj(after, (long)(60 * 60 * 24 * 31 * context->duration_months)); - else if (context->duration_years) - X509_gmtime_adj(after, (long)(60 * 60 * 24 * 365 * context->duration_years)); + long duration = context->duration_months * 31l + context->duration_years * 365l; + duration *= 60l * 60l * 24l; + X509_gmtime_adj(after, duration); } X509_set_pubkey(context->x509, context->pkey); name = X509_get_subject_name(context->x509);