version 1.458, 2022/08/05 05:01:40 |
version 1.459, 2022/08/11 01:56:51 |
|
|
} |
} |
|
|
static void |
static void |
|
parse_hex_u64(const char *s, uint64_t *up) |
|
{ |
|
char *ep; |
|
unsigned long long ull; |
|
|
|
errno = 0; |
|
ull = strtoull(s, &ep, 16); |
|
if (*s == '\0' || *ep != '\0') |
|
fatal("Invalid certificate time: not a number"); |
|
if (errno == ERANGE && ull == ULONG_MAX) |
|
fatal_fr(SSH_ERR_SYSTEM_ERROR, "Invalid certificate time"); |
|
*up = (uint64_t)ull; |
|
} |
|
|
|
static void |
parse_cert_times(char *timespec) |
parse_cert_times(char *timespec) |
{ |
{ |
char *from, *to; |
char *from, *to; |
|
|
|
|
/* |
/* |
* from:to, where |
* from:to, where |
* from := [+-]timespec | YYYYMMDD | YYYYMMDDHHMMSS | "always" |
* from := [+-]timespec | YYYYMMDD | YYYYMMDDHHMMSS | 0x... | "always" |
* to := [+-]timespec | YYYYMMDD | YYYYMMDDHHMMSS | "forever" |
* to := [+-]timespec | YYYYMMDD | YYYYMMDDHHMMSS | 0x... | "forever" |
*/ |
*/ |
from = xstrdup(timespec); |
from = xstrdup(timespec); |
to = strchr(from, ':'); |
to = strchr(from, ':'); |
|
|
cert_valid_from = parse_relative_time(from, now); |
cert_valid_from = parse_relative_time(from, now); |
else if (strcmp(from, "always") == 0) |
else if (strcmp(from, "always") == 0) |
cert_valid_from = 0; |
cert_valid_from = 0; |
|
else if (strncmp(from, "0x", 2) == 0) |
|
parse_hex_u64(from, &cert_valid_from); |
else if (parse_absolute_time(from, &cert_valid_from) != 0) |
else if (parse_absolute_time(from, &cert_valid_from) != 0) |
fatal("Invalid from time \"%s\"", from); |
fatal("Invalid from time \"%s\"", from); |
|
|
|
|
cert_valid_to = parse_relative_time(to, now); |
cert_valid_to = parse_relative_time(to, now); |
else if (strcmp(to, "forever") == 0) |
else if (strcmp(to, "forever") == 0) |
cert_valid_to = ~(u_int64_t)0; |
cert_valid_to = ~(u_int64_t)0; |
|
else if (strncmp(from, "0x", 2) == 0) |
|
parse_hex_u64(to, &cert_valid_to); |
else if (parse_absolute_time(to, &cert_valid_to) != 0) |
else if (parse_absolute_time(to, &cert_valid_to) != 0) |
fatal("Invalid to time \"%s\"", to); |
fatal("Invalid to time \"%s\"", to); |
|
|