1 .\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
9 .de Vb \" Begin verbatim text
14 .de Ve \" End verbatim text
18 .\" Set up some character translations and predefined strings. \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote. \*(C+ will
21 .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
29 . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
49 .\" If the F register is turned on, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD. Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
54 .\" Avoid warning from groff about undefined register 'F'.
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{
62 . tm Index:\\$1\t\\n%\t"\\$2"
72 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
73 .\" Fear. Run. Save yourself. No user-serviceable parts.
74 . \" fudge factors for nroff and troff
83 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89 . \" simple accents for nroff and troff
99 . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
100 . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
101 . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
102 . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
103 . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
104 . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
106 . \" troff and (daisy-wheel) nroff accents
107 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
108 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
109 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
110 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
111 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
112 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
113 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
114 .ds ae a\h'-(\w'a'u*4/10)'e
115 .ds Ae A\h'-(\w'A'u*4/10)'E
116 . \" corrections for vroff
117 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
118 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
119 . \" for low resolution devices (crt and lpr)
120 .if \n(.H>23 .if \n(.V>19 \
133 .\" ========================================================================
135 .IX Title "ASN1_TIME_set 3"
136 .TH ASN1_TIME_set 3 "2016-09-22" "1.0.2i" "OpenSSL"
137 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
138 .\" way too many mistakes in technical documents.
142 ASN1_TIME_set, ASN1_TIME_adj, ASN1_TIME_check, ASN1_TIME_set_string,
143 ASN1_TIME_print, ASN1_TIME_diff \- ASN.1 Time functions.
145 .IX Header "SYNOPSIS"
147 \& ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t);
148 \& ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
149 \& int offset_day, long offset_sec);
150 \& int ASN1_TIME_set_string(ASN1_TIME *s, const char *str);
151 \& int ASN1_TIME_check(const ASN1_TIME *t);
152 \& int ASN1_TIME_print(BIO *b, const ASN1_TIME *s);
154 \& int ASN1_TIME_diff(int *pday, int *psec,
155 \& const ASN1_TIME *from, const ASN1_TIME *to);
158 .IX Header "DESCRIPTION"
159 The function \fIASN1_TIME_set()\fR sets the \s-1ASN1_TIME\s0 structure \fBs\fR to the
160 time represented by the time_t value \fBt\fR. If \fBs\fR is \s-1NULL\s0 a new \s-1ASN1_TIME\s0
161 structure is allocated and returned.
163 \&\fIASN1_TIME_adj()\fR sets the \s-1ASN1_TIME\s0 structure \fBs\fR to the time represented
164 by the time \fBoffset_day\fR and \fBoffset_sec\fR after the time_t value \fBt\fR.
165 The values of \fBoffset_day\fR or \fBoffset_sec\fR can be negative to set a
166 time before \fBt\fR. The \fBoffset_sec\fR value can also exceed the number of
167 seconds in a day. If \fBs\fR is \s-1NULL\s0 a new \s-1ASN1_TIME\s0 structure is allocated
170 \&\fIASN1_TIME_set_string()\fR sets \s-1ASN1_TIME\s0 structure \fBs\fR to the time
171 represented by string \fBstr\fR which must be in appropriate \s-1ASN.1\s0 time
172 format (for example \s-1YYMMDDHHMMSSZ\s0 or \s-1YYYYMMDDHHMMSSZ\s0).
174 \&\fIASN1_TIME_check()\fR checks the syntax of \s-1ASN1_TIME\s0 structure \fBs\fR.
176 \&\fIASN1_TIME_print()\fR prints out the time \fBs\fR to \s-1BIO \s0\fBb\fR in human readable
177 format. It will be of the format \s-1MMM DD HH:MM:SS YYYY\s0 [\s-1GMT\s0], for example
178 \&\*(L"Feb 3 00:55:52 2015 \s-1GMT\*(R"\s0 it does not include a newline. If the time
179 structure has invalid format it prints out \*(L"Bad time value\*(R" and returns
182 \&\fIASN1_TIME_diff()\fR sets \fB*pday\fR and \fB*psec\fR to the time difference between
183 \&\fBfrom\fR and \fBto\fR. If \fBto\fR represents a time later than \fBfrom\fR then
184 one or both (depending on the time difference) of \fB*pday\fR and \fB*psec\fR
185 will be positive. If \fBto\fR represents a time earlier than \fBfrom\fR then
186 one or both of \fB*pday\fR and \fB*psec\fR will be negative. If \fBto\fR and \fBfrom\fR
187 represent the same time then \fB*pday\fR and \fB*psec\fR will both be zero.
188 If both \fB*pday\fR and \fB*psec\fR are non-zero they will always have the same
189 sign. The value of \fB*psec\fR will always be less than the number of seconds
190 in a day. If \fBfrom\fR or \fBto\fR is \s-1NULL\s0 the current time is used.
193 The \s-1ASN1_TIME\s0 structure corresponds to the \s-1ASN.1\s0 structure \fBTime\fR
194 defined in \s-1RFC5280\s0 et al. The time setting functions obey the rules outlined
195 in \s-1RFC5280:\s0 if the date can be represented by UTCTime it is used, else
196 GeneralizedTime is used.
198 The \s-1ASN1_TIME\s0 structure is represented as an \s-1ASN1_STRING\s0 internally and can
199 be freed up using \fIASN1_STRING_free()\fR.
201 The \s-1ASN1_TIME\s0 structure can represent years from 0000 to 9999 but no attempt
202 is made to correct ancient calendar changes (for example from Julian to
203 Gregorian calendars).
205 Some applications add offset times directly to a time_t value and pass the
206 results to \fIASN1_TIME_set()\fR (or equivalent). This can cause problems as the
207 time_t value can overflow on some systems resulting in unexpected results.
208 New applications should use \fIASN1_TIME_adj()\fR instead and pass the offset value
209 in the \fBoffset_sec\fR and \fBoffset_day\fR parameters instead of directly
210 manipulating a time_t value.
213 \&\fIASN1_TIME_print()\fR currently does not print out the time zone: it either prints
214 out \*(L"\s-1GMT\*(R"\s0 or nothing. But all certificates complying with \s-1RFC5280\s0 et al use \s-1GMT\s0
217 .IX Header "EXAMPLES"
218 Set a time structure to one hour after the current time and print it out:
222 \& #include <openssl/asn1.h>
227 \& tm = ASN1_TIME_adj(NULL, t, 0, 60 * 60);
228 \& b = BIO_new_fp(stdout, BIO_NOCLOSE);
229 \& ASN1_TIME_print(b, tm);
230 \& ASN1_STRING_free(tm);
234 Determine if one time is later or sooner than the current time:
239 \& if (!ASN1_TIME_diff(&day, &sec, NULL, to))
240 \& /* Invalid time format */
242 \& if (day > 0 || sec > 0)
243 \& printf("Later\en");
244 \& else if (day < 0 || sec < 0)
245 \& printf("Sooner\en");
247 \& printf("Same\en");
250 .IX Header "RETURN VALUES"
251 \&\fIASN1_TIME_set()\fR and \fIASN1_TIME_adj()\fR return a pointer to an \s-1ASN1_TIME\s0 structure
252 or \s-1NULL\s0 if an error occurred.
254 \&\fIASN1_TIME_set_string()\fR returns 1 if the time value is successfully set and
257 \&\fIASN1_TIME_check()\fR returns 1 if the structure is syntactically correct and 0
260 \&\fIASN1_TIME_print()\fR returns 1 if the time is successfully printed out and 0 if
261 an error occurred (I/O error or invalid time format).
263 \&\fIASN1_TIME_diff()\fR returns 1 for sucess and 0 for failure. It can fail if the
264 pass \s-1ASN1_TIME\s0 structure has invalid syntax for example.