File: ocsptool-args.def

package info (click to toggle)
gnutls28 3.6.7-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 67,368 kB
  • sloc: ansic: 295,691; asm: 70,637; sh: 15,067; makefile: 6,288; yacc: 1,840; lisp: 1,371; cpp: 1,358; perl: 1,030; sed: 16
file content (317 lines) | stat: -rw-r--r-- 9,900 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
AutoGen Definitions options;
prog-name     = ocsptool;
prog-title    = "GnuTLS OCSP tool";
prog-desc     = "Program to handle OCSP request/responses.";
detail    = "ocsptool is a program that can parse and print information about
OCSP requests/responses, generate requests and verify responses. Unlike
other GnuTLS applications it outputs DER encoded structures by default
unless the '--outpem' option is specified.";
short-usage   = "ocsptool [options]\nocsptool --help for usage instructions.\n";
explain       = "";

doc-section = {
  ds-type = 'DESCRIPTION';
  ds-format = 'texi';
  ds-text   = <<-_EOT_
@subheading On verification
Responses are typically signed/issued by designated certificates or
certificate authorities and thus this tool requires on verification
the certificate of the issuer or the full certificate chain in order to
determine the appropriate signing authority. The specified certificate
of the issuer is assumed trusted.
_EOT_;
};

#define  INFILE_OPT   1
#define  OUTFILE_OPT  1
#define  VERBOSE_OPT  1
#include args-std.def

flag = {
    name      = ask;
    arg-type  = string;
    arg-name  = "server name|url";
    arg-optional;
    descrip   = "Ask an OCSP/HTTP server on a certificate validity";
    doc = "Connects to the specified HTTP OCSP server and queries on the validity of the loaded certificate.
Its argument can be a URL or a plain server name. It can be combined with --load-chain, where it checks
all certificates in the provided chain, or with --load-cert and
--load-issuer options. The latter checks the provided certificate
against its specified issuer certificate.";
};

flag = {
    name      = verify-response;
    value     = e;
    descrip   = "Verify response";
    doc = "Verifies the provided OCSP response against the system trust
anchors (unless --load-trust is provided). It requires the --load-signer
or --load-chain options to obtain the signer of the OCSP response.";
};

flag = {
    name      = request-info;
    value     = i;
    descrip   = "Print information on a OCSP request";
    doc = "Display detailed information on the provided OCSP request.";
};

flag = {
    name      = response-info;
    value     = j;
    descrip   = "Print information on a OCSP response";
    doc = "Display detailed information on the provided OCSP response.";
};

flag = {
    name      = generate-request;
    value     = q;
    descrip   = "Generates an OCSP request";
    doc = "";
};

flag = {
    name      = nonce;
    disabled  = yes;
    disable   = "no";
    descrip   = "Use (or not) a nonce to OCSP request";
    doc = "";
};

flag = {
    name      = load-chain;
    arg-type  = file;
    file-exists = yes;
    descrip   = "Reads a set of certificates forming a chain from file";
    doc = "";
};

flag = {
    name      = load-issuer;
    arg-type  = file;
    file-exists = yes;
    descrip   = "Reads issuer's certificate from file";
    doc = "";
};

flag = {
    name      = load-cert;
    arg-type  = file;
    file-exists = yes;
    descrip   = "Reads the certificate to check from file";
    doc = "";
};

flag = {
    name      = load-trust;
    arg-type  = file;
    file-exists = yes;
    descrip   = "Read OCSP trust anchors from file";
    flags-cant = load-signer;
    doc = "When verifying an OCSP response read the trust anchors from the
provided file. When this is not provided, the system's trust anchors will be
used.";
};

flag = {
    name      = load-signer;
    arg-type  = file;
    file-exists = yes;
    descrip   = "Reads the OCSP response signer from file";
    flags-cant = load-trust;
    doc = "";
};

flag = {
    name      = inder;
    disabled;
    disable   = "no";
    descrip   = "Use DER format for input certificates and private keys";
    doc      = "";
};

flag = {
    name      = outder;
    descrip   = "Use DER format for output of responses (this is the default)";
    doc = "The output will be in DER encoded format. Unlike other GnuTLS tools, this is the default for this tool";
};

flag = {
    name      = outpem;
    descrip   = "Use PEM format for output of responses";
    doc       = "The output will be in PEM format.";
};

flag = {
    name      = load-request;
    value     = Q;
    arg-type  = file;
    file-exists = yes;
    descrip   = "Reads the DER encoded OCSP request from file";
    doc      = "";
};

flag = {
    name      = load-response;
    value     = S;
    arg-type  = file;
    file-exists = yes;
    descrip   = "Reads the DER encoded OCSP response from file";
    doc      = "";
};

flag = {
    name      = ignore-errors;
    descrip   = "Ignore any verification errors";
    doc = "";
};

flag = {
    name      = verify-allow-broken;
    descrip   = "Allow broken algorithms, such as MD5 for verification";
    doc = "This can be combined with --verify-response.";
};

doc-section = {
  ds-type = 'SEE ALSO';
  ds-format = 'texi';
  ds-text   = <<-_EOT_
    certtool (1)
_EOT_;
};

doc-section = {
  ds-type = 'EXAMPLES';
  ds-format = 'texi';
  ds-text   = <<-_EOF_
@subheading Print information about an OCSP request

To parse an OCSP request and print information about the content, the
@code{-i} or @code{--request-info} parameter may be used as follows.
The @code{-Q} parameter specify the name of the file containing the
OCSP request, and it should contain the OCSP request in binary DER
format.

@example
$ ocsptool -i -Q ocsp-request.der
@end example

The input file may also be sent to standard input like this:

@example
$ cat ocsp-request.der | ocsptool --request-info
@end example

@subheading Print information about an OCSP response

Similar to parsing OCSP requests, OCSP responses can be parsed using
the @code{-j} or @code{--response-info} as follows.

@example
$ ocsptool -j -Q ocsp-response.der
$ cat ocsp-response.der | ocsptool --response-info
@end example

@subheading Generate an OCSP request

The @code{-q} or @code{--generate-request} parameters are used to
generate an OCSP request.  By default the OCSP request is written to
standard output in binary DER format, but can be stored in a file
using @code{--outfile}.  To generate an OCSP request the issuer of the
certificate to check needs to be specified with @code{--load-issuer}
and the certificate to check with @code{--load-cert}.  By default PEM
format is used for these files, although @code{--inder} can be used to
specify that the input files are in DER format.

@example
$ ocsptool -q --load-issuer issuer.pem --load-cert client.pem \
           --outfile ocsp-request.der
@end example

When generating OCSP requests, the tool will add an OCSP extension
containing a nonce.  This behaviour can be disabled by specifying
@code{--no-nonce}.

@subheading Verify signature in OCSP response

To verify the signature in an OCSP response the @code{-e} or
@code{--verify-response} parameter is used.  The tool will read an
OCSP response in DER format from standard input, or from the file
specified by @code{--load-response}.  The OCSP response is verified
against a set of trust anchors, which are specified using
@code{--load-trust}.  The trust anchors are concatenated certificates
in PEM format.  The certificate that signed the OCSP response needs to
be in the set of trust anchors, or the issuer of the signer
certificate needs to be in the set of trust anchors and the OCSP
Extended Key Usage bit has to be asserted in the signer certificate.

@example
$ ocsptool -e --load-trust issuer.pem \
           --load-response ocsp-response.der
@end example

The tool will print status of verification.

@subheading Verify signature in OCSP response against given certificate

It is possible to override the normal trust logic if you know that a
certain certificate is supposed to have signed the OCSP response, and
you want to use it to check the signature.  This is achieved using
@code{--load-signer} instead of @code{--load-trust}.  This will load
one certificate and it will be used to verify the signature in the
OCSP response.  It will not check the Extended Key Usage bit.

@example
$ ocsptool -e --load-signer ocsp-signer.pem \
           --load-response ocsp-response.der
@end example

This approach is normally only relevant in two situations.  The first
is when the OCSP response does not contain a copy of the signer
certificate, so the @code{--load-trust} code would fail.  The second
is if you want to avoid the indirect mode where the OCSP response
signer certificate is signed by a trust anchor.

@subheading Real-world example

Here is an example of how to generate an OCSP request for a
certificate and to verify the response.  For illustration we'll use
the @code{blog.josefsson.org} host, which (as of writing) uses a
certificate from CACert.  First we'll use @code{gnutls-cli} to get a
copy of the server certificate chain.  The server is not required to
send this information, but this particular one is configured to do so.

@example
$ echo | gnutls-cli -p 443 blog.josefsson.org --save-cert chain.pem
@end example

The saved certificates normally contain a pointer to where the OCSP
responder is located, in the Authority Information Access Information
extension.  For example, from @code{certtool -i < chain.pem} there is
this information:

@example
		Authority Information Access Information (not critical):
			Access Method: 1.3.6.1.5.5.7.48.1 (id-ad-ocsp)
			Access Location URI: https://ocsp.CAcert.org/
@end example

This means that ocsptool can discover the servers to contact over HTTP.
We can now request information on the chain certificates.

@example
$ ocsptool --ask --load-chain chain.pem
@end example

The request is sent via HTTP to the OCSP server address found in
the certificates. It is possible to override the address of the
OCSP server as well as ask information on a particular certificate
using --load-cert and --load-issuer.

@example
$ ocsptool --ask https://ocsp.CAcert.org/ --load-chain chain.pem
@end example

_EOF_;
};