summaryrefslogtreecommitdiff
path: root/ssh-keygen.c
diff options
context:
space:
mode:
authordjm@openbsd.org@openbsd.org <djm@openbsd.org@openbsd.org>2017-11-03 05:14:04 +0000
committerDamien Miller <djm@mindrot.org>2017-11-03 16:20:41 +1100
commitd52131a98316e76c0caa348f09bf6f7b9b01a1b9 (patch)
tree3328babb2dfeafda48da072003b5bff9e069c9c7 /ssh-keygen.c
parentfbe8e7ac94c2fa380421a9205a8bc966549c2f91 (diff)
upstream commit
allow certificate validity intervals that specify only a start or stop time (we already support specifying both or neither) OpenBSD-Commit-ID: 9be486545603c003030bdb5c467d1318b46b4e42
Diffstat (limited to 'ssh-keygen.c')
-rw-r--r--ssh-keygen.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c
index 835f7d016..02f9b3fb8 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keygen.c,v 1.307 2017/07/07 03:53:12 djm Exp $ */ 1/* $OpenBSD: ssh-keygen.c,v 1.308 2017/11/03 05:14:04 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1832,7 +1832,7 @@ parse_absolute_time(const char *s)
1832 s, s + 4, s + 6, s + 8, s + 10, s + 12); 1832 s, s + 4, s + 6, s + 8, s + 10, s + 12);
1833 break; 1833 break;
1834 default: 1834 default:
1835 fatal("Invalid certificate time format %s", s); 1835 fatal("Invalid certificate time format \"%s\"", s);
1836 } 1836 }
1837 1837
1838 memset(&tm, 0, sizeof(tm)); 1838 memset(&tm, 0, sizeof(tm));
@@ -1865,8 +1865,8 @@ parse_cert_times(char *timespec)
1865 1865
1866 /* 1866 /*
1867 * from:to, where 1867 * from:to, where
1868 * from := [+-]timespec | YYYYMMDD | YYYYMMDDHHMMSS 1868 * from := [+-]timespec | YYYYMMDD | YYYYMMDDHHMMSS | "always"
1869 * to := [+-]timespec | YYYYMMDD | YYYYMMDDHHMMSS 1869 * to := [+-]timespec | YYYYMMDD | YYYYMMDDHHMMSS | "forever"
1870 */ 1870 */
1871 from = xstrdup(timespec); 1871 from = xstrdup(timespec);
1872 to = strchr(from, ':'); 1872 to = strchr(from, ':');
@@ -1876,11 +1876,15 @@ parse_cert_times(char *timespec)
1876 1876
1877 if (*from == '-' || *from == '+') 1877 if (*from == '-' || *from == '+')
1878 cert_valid_from = parse_relative_time(from, now); 1878 cert_valid_from = parse_relative_time(from, now);
1879 else if (strcmp(from, "always") == 0)
1880 cert_valid_from = 0;
1879 else 1881 else
1880 cert_valid_from = parse_absolute_time(from); 1882 cert_valid_from = parse_absolute_time(from);
1881 1883
1882 if (*to == '-' || *to == '+') 1884 if (*to == '-' || *to == '+')
1883 cert_valid_to = parse_relative_time(to, now); 1885 cert_valid_to = parse_relative_time(to, now);
1886 else if (strcmp(to, "forever") == 0)
1887 cert_valid_to = ~(u_int64_t)0;
1884 else 1888 else
1885 cert_valid_to = parse_absolute_time(to); 1889 cert_valid_to = parse_absolute_time(to);
1886 1890