1.\" $OpenBSD: X509_get0_notBefore.3,v 1.7 2024/03/05 18:30:40 tb Exp $ 2.\" content checked up to: OpenSSL 27b138e9 May 19 00:16:38 2017 +0000 3.\" 4.\" Copyright (c) 2018, 2020 Ingo Schwarze <schwarze@openbsd.org> 5.\" 6.\" Permission to use, copy, modify, and distribute this software for any 7.\" purpose with or without fee is hereby granted, provided that the above 8.\" copyright notice and this permission notice appear in all copies. 9.\" 10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" 18.Dd $Mdocdate: March 5 2024 $ 19.Dt X509_GET0_NOTBEFORE 3 20.Os 21.Sh NAME 22.Nm X509_get0_notBefore , 23.Nm X509_get0_notAfter , 24.Nm X509_getm_notBefore , 25.Nm X509_getm_notAfter , 26.Nm X509_get_notBefore , 27.Nm X509_get_notAfter , 28.Nm X509_CRL_get0_lastUpdate , 29.Nm X509_CRL_get0_nextUpdate , 30.Nm X509_CRL_get_lastUpdate , 31.Nm X509_CRL_get_nextUpdate , 32.Nm X509_set1_notBefore , 33.Nm X509_set1_notAfter , 34.Nm X509_set_notBefore , 35.Nm X509_set_notAfter , 36.Nm X509_CRL_set1_lastUpdate , 37.Nm X509_CRL_set1_nextUpdate , 38.Nm X509_CRL_set_lastUpdate , 39.Nm X509_CRL_set_nextUpdate 40.Nd get and set certificate and CRL validity dates 41.Sh SYNOPSIS 42.In openssl/x509.h 43.Ft const ASN1_TIME * 44.Fo X509_get0_notBefore 45.Fa "const X509 *x" 46.Fc 47.Ft const ASN1_TIME * 48.Fo X509_get0_notAfter 49.Fa "const X509 *x" 50.Fc 51.Ft ASN1_TIME * 52.Fo X509_getm_notBefore 53.Fa "const X509 *x" 54.Fc 55.Ft ASN1_TIME * 56.Fo X509_getm_notAfter 57.Fa "const X509 *x" 58.Fc 59.Ft ASN1_TIME * 60.Fo X509_get_notBefore 61.Fa "const X509 *x" 62.Fc 63.Ft ASN1_TIME * 64.Fo X509_get_notAfter 65.Fa "const X509 *x" 66.Fc 67.Ft const ASN1_TIME * 68.Fo X509_CRL_get0_lastUpdate 69.Fa "const X509_CRL *crl" 70.Fc 71.Ft const ASN1_TIME * 72.Fo X509_CRL_get0_nextUpdate 73.Fa "const X509_CRL *crl" 74.Fc 75.Ft ASN1_TIME * 76.Fo X509_CRL_get_lastUpdate 77.Fa "X509_CRL *crl" 78.Fc 79.Ft ASN1_TIME * 80.Fo X509_CRL_get_nextUpdate 81.Fa "X509_CRL *crl" 82.Fc 83.Ft int 84.Fo X509_set1_notBefore 85.Fa "X509 *x" 86.Fa "const ASN1_TIME *tm" 87.Fc 88.Ft int 89.Fo X509_set1_notAfter 90.Fa "X509 *x" 91.Fa "const ASN1_TIME *tm" 92.Fc 93.Ft int 94.Fo X509_set_notBefore 95.Fa "X509 *x" 96.Fa "const ASN1_TIME *tm" 97.Fc 98.Ft int 99.Fo X509_set_notAfter 100.Fa "X509 *x" 101.Fa "const ASN1_TIME *tm" 102.Fc 103.Ft int 104.Fo X509_CRL_set1_lastUpdate 105.Fa "X509_CRL *crl" 106.Fa "const ASN1_TIME *tm" 107.Fc 108.Ft int 109.Fo X509_CRL_set1_nextUpdate 110.Fa "X509_CRL *crl" 111.Fa "const ASN1_TIME *tm" 112.Fc 113.Ft int 114.Fo X509_CRL_set_lastUpdate 115.Fa "X509_CRL *crl" 116.Fa "const ASN1_TIME *tm" 117.Fc 118.Ft int 119.Fo X509_CRL_set_nextUpdate 120.Fa "X509_CRL *crl" 121.Fa "const ASN1_TIME *tm" 122.Fc 123.Sh DESCRIPTION 124.Fn X509_getm_notBefore 125and 126.Fn X509_getm_notAfter 127return pointers to the 128.Fa notBefore 129and 130.Fa notAfter 131fields of the validity period of the certificate 132.Fa x , 133respectively. 134.Fn X509_get_notBefore 135and 136.Fn X509_get_notAfter 137are deprecated aliases implemented as macros. 138.Pp 139.Fn X509_get0_notBefore 140and 141.Fn X509_get0_notAfter 142are identical except for the const qualifier on the return type. 143.Pp 144.Fn X509_CRL_get0_lastUpdate 145is misnamed in a confusing way: it returns a pointer to the 146.Fa thisUpdate 147field of the 148.Fa crl , 149indicating the time when this 150.Fa crl 151was issued. 152.Pp 153.Fn X509_CRL_get0_nextUpdate 154returns a pointer to the 155.Fa nextUpdate 156field of the 157.Fa crl , 158indicating the time when issuing the subsequent CRL will be due. 159.Pp 160.Fn X509_CRL_get_lastUpdate 161and 162.Fn X509_CRL_get_nextUpdate 163are deprecated and identical except for the const qualifier 164on the argument and on the return type. 165.Pp 166.Fn X509_set1_notBefore , 167.Fn X509_set1_notAfter , 168.Fn X509_CRL_set1_lastUpdate , 169and 170.Fn X509_CRL_set1_nextUpdate 171set the 172.Fa notBefore , 173.Fa notAfter , 174.Fa thisUpdate Pq sic!\& , 175or 176.Fa nextUpdate 177field of 178.Fa x 179or 180.Fa crl , 181respectively, to a deep copy of 182.Fa tm 183and free the 184.Vt ASN1_TIME 185value that they replace. 186.Pp 187.Fn X509_set_notBefore , 188.Fn X509_set_notAfter , 189.Fn X509_CRL_set_lastUpdate , 190and 191.Fn X509_CRL_set_nextUpdate 192are deprecated aliases. 193.Sh RETURN VALUES 194The 195.Sy get 196functions return internal pointers 197which must not be freed by the application, or 198.Dv NULL 199if the requested field is not available. 200They may crash with a 201.Dv NULL 202pointer access if 203.Fa x 204or 205.Fa crl 206is 207.Dv NULL . 208.Pp 209The 210.Sy set 211functions return 1 on success or 0 on failure. 212They fail if 213.Fa x 214is 215.Dv NULL 216or does not contain a 217.Fa validity 218substructure, if 219.Fa crl 220is 221.Dv NULL , 222or if 223.Xr ASN1_STRING_dup 3 224fails. 225.Pp 226Except for some cases of 227.Xr ASN1_STRING_dup 3 228failure, these functions do not support 229determining reasons for failure with 230.Xr ERR_get_error 3 . 231.Sh SEE ALSO 232.Xr ASN1_TIME_set 3 , 233.Xr X509_cmp_time 3 , 234.Xr X509_CRL_get0_by_serial 3 , 235.Xr X509_CRL_new 3 , 236.Xr X509_get_subject_name 3 , 237.Xr X509_new 3 , 238.Xr X509_sign 3 , 239.Xr X509_VAL_new 3 , 240.Xr X509_verify_cert 3 241.Sh HISTORY 242.Fn X509_get_notBefore , 243.Fn X509_get_notAfter , 244.Fn X509_set_notBefore , 245and 246.Fn X509_set_notAfter 247first appeared in SSLeay 0.6.5 and have been available since 248.Ox 2.4 . 249.Pp 250.Fn X509_CRL_get_lastUpdate 251and 252.Fn X509_CRL_get_nextUpdate 253first appeared in OpenSSL 0.9.2 and have been available since 254.Ox 2.6 . 255.Pp 256.Fn X509_CRL_set_lastUpdate 257and 258.Fn X509_CRL_set_nextUpdate 259first appeared in OpenSSL 0.9.7 and have been available since 260.Ox 3.2 . 261.Pp 262The remaining functions first appeared in OpenSSL 1.1.0 263and have been available since 264.Ox 6.3 . 265