Add X509_getm_notBefore, X509_getm_notAfter
Add mutable versions of X509_get0_notBefore and X509_get0_notAfter.
Rename X509_SIG_get0_mutable to X509_SIG_getm.
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
diff --git a/apps/apps.c b/apps/apps.c
index 23c6569..522db71 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -2593,33 +2593,19 @@
int set_cert_times(X509 *x, const char *startdate, const char *enddate,
int days)
{
- int rv = 0;
- ASN1_TIME *tm = ASN1_TIME_new();
- if (tm == NULL)
- goto err;
if (startdate == NULL || strcmp(startdate, "today") == 0) {
- if (!X509_gmtime_adj(tm, 0))
- goto err;
- } else if (!ASN1_TIME_set_string(tm, startdate)) {
- goto err;
+ if (X509_gmtime_adj(X509_getm_notBefore(x), 0) == NULL)
+ return 0;
+ } else {
+ if (!ASN1_TIME_set_string(X509_getm_notBefore(x), startdate))
+ return 0;
}
-
- if (!X509_set1_notBefore(x, tm))
- goto err;
-
if (enddate == NULL) {
- if (!X509_time_adj_ex(tm, days, 0, NULL))
- goto err;
- } else if (!ASN1_TIME_set_string(tm, enddate)) {
- goto err;
+ if (X509_time_adj_ex(X509_getm_notAfter(x), days, 0, NULL)
+ == NULL)
+ return 0;
+ } else if (!ASN1_TIME_set_string(X509_getm_notAfter(x), enddate)) {
+ return 0;
}
-
- if (!X509_set1_notAfter(x, tm))
- goto err;
-
- rv = 1;
-
- err:
- ASN1_TIME_free(tm);
- return rv;
+ return 1;
}