1ocsptool(1) User Commands ocsptool(1)
2
3
4
6 ocsptool - GnuTLS OCSP tool
7
9 ocsptool [-flags] [-flag [value]] [--option-name[[=| ]value]]
10
11 All arguments must be options.
12
14 On verification
15 Responses are typically signed/issued by designated certificates or
16 certificate authorities and thus this tool requires on verification the
17 certificate of the issuer or the full certificate chain in order to de‐
18 termine the appropriate signing authority. The specified certificate of
19 the issuer is assumed trusted.
20
21
22
24 -d num, --debug=num
25 Enable debugging. This option takes an integer number as its
26 argument. The value of num is constrained to being:
27 in the range 0 through 9999
28
29 Specifies the debug level.
30
31 -V, --verbose
32 More verbose output.
33
34
35 --infile=file
36 Input file.
37
38
39 --outfile=str
40 Output file.
41
42
43 --ask=server name|url
44 Ask an OCSP/HTTP server on a certificate validity.
45
46 Connects to the specified HTTP OCSP server and queries on the
47 validity of the loaded certificate. Its argument can be a URL
48 or a plain server name. It can be combined with --load-chain,
49 where it checks all certificates in the provided chain, or with
50 --load-cert and --load-issuer options. The latter checks the
51 provided certificate against its specified issuer certificate.
52
53 -e, --verify-response
54 Verify response.
55
56 Verifies the provided OCSP response against the system trust an‐
57 chors (unless --load-trust is provided). It requires the
58 --load-signer or --load-chain options to obtain the signer of
59 the OCSP response.
60
61 -i, --request-info
62 Print information on a OCSP request.
63
64 Display detailed information on the provided OCSP request.
65
66 -j, --response-info
67 Print information on a OCSP response.
68
69 Display detailed information on the provided OCSP response.
70
71 -q, --generate-request
72 Generates an OCSP request.
73
74
75 --nonce, --no-nonce
76 Use (or not) a nonce to OCSP request. The no-nonce form will
77 disable the option.
78
79
80 --load-chain=file
81 Reads a set of certificates forming a chain from file.
82
83
84 --load-issuer=file
85 Reads issuer's certificate from file.
86
87
88 --load-cert=file
89 Reads the certificate to check from file.
90
91
92 --load-trust=file
93 Read OCSP trust anchors from file. This option must not appear
94 in combination with any of the following options: load-signer.
95
96 When verifying an OCSP response read the trust anchors from the
97 provided file. When this is not provided, the system's trust an‐
98 chors will be used.
99
100 --load-signer=file
101 Reads the OCSP response signer from file. This option must not
102 appear in combination with any of the following options: load-
103 trust.
104
105
106 --inder, --no-inder
107 Use DER format for input certificates and private keys. The
108 no-inder form will disable the option.
109
110
111 --outder
112 Use DER format for output of responses (this is the default).
113
114 The output will be in DER encoded format. Unlike other GnuTLS
115 tools, this is the default for this tool
116
117 --outpem
118 Use PEM format for output of responses.
119
120 The output will be in PEM format.
121
122 -Q file, --load-request=file
123 Reads the DER encoded OCSP request from file.
124
125
126 -S file, --load-response=file
127 Reads the DER encoded OCSP response from file.
128
129
130 --ignore-errors
131 Ignore any verification errors.
132
133
134 --verify-allow-broken
135 Allow broken algorithms, such as MD5 for verification.
136
137 This can be combined with --verify-response.
138
139 --attime=timestamp
140 Perform validation at the timestamp instead of the system time.
141
142 timestamp is an instance in time encoded as Unix time or in a
143 human
144 readable timestring such as "29 Feb 2004", "2004-02-29". Full
145 documentation available at <https://www.gnu.org/software/core‐
146 utils/manual/html_node/Date-input-formats.html> or locally via
147 info '(coreutils) date invocation'.
148
149 -v arg, --version=arg
150 Output version of program and exit. The default mode is `v', a
151 simple version. The `c' mode will print copyright information
152 and `n' will print the full copyright notice.
153
154 -h, --help
155 Display usage information and exit.
156
157 -!, --more-help
158 Pass the extended usage information through a pager.
159
160
161
163 Print information about an OCSP request
164
165 To parse an OCSP request and print information about the content, the
166 -i or --request-info parameter may be used as follows. The -Q parame‐
167 ter specify the name of the file containing the OCSP request, and it
168 should contain the OCSP request in binary DER format.
169
170 $ ocsptool -i -Q ocsp-request.der
171
172 The input file may also be sent to standard input like this:
173
174 $ cat ocsp-request.der | ocsptool --request-info
175
176 Print information about an OCSP response
177
178 Similar to parsing OCSP requests, OCSP responses can be parsed using
179 the -j or --response-info as follows.
180
181 $ ocsptool -j -Q ocsp-response.der
182 $ cat ocsp-response.der | ocsptool --response-info
183
184 Generate an OCSP request
185
186 The -q or --generate-request parameters are used to generate an OCSP
187 request. By default the OCSP request is written to standard output in
188 binary DER format, but can be stored in a file using --outfile. To
189 generate an OCSP request the issuer of the certificate to check needs
190 to be specified with --load-issuer and the certificate to check with
191 --load-cert. By default PEM format is used for these files, although
192 --inder can be used to specify that the input files are in DER format.
193
194 $ ocsptool -q --load-issuer issuer.pem --load-cert client.pem --outfile ocsp-request.der
195
196 When generating OCSP requests, the tool will add an OCSP extension con‐
197 taining a nonce. This behaviour can be disabled by specifying
198 --no-nonce.
199
200 Verify signature in OCSP response
201
202 To verify the signature in an OCSP response the -e or --verify-response
203 parameter is used. The tool will read an OCSP response in DER format
204 from standard input, or from the file specified by --load-response.
205 The OCSP response is verified against a set of trust anchors, which are
206 specified using --load-trust. The trust anchors are concatenated cer‐
207 tificates in PEM format. The certificate that signed the OCSP response
208 needs to be in the set of trust anchors, or the issuer of the signer
209 certificate needs to be in the set of trust anchors and the OCSP Ex‐
210 tended Key Usage bit has to be asserted in the signer certificate.
211
212 $ ocsptool -e --load-trust issuer.pem --load-response ocsp-response.der
213
214 The tool will print status of verification.
215
216 Verify signature in OCSP response against given certificate
217
218 It is possible to override the normal trust logic if you know that a
219 certain certificate is supposed to have signed the OCSP response, and
220 you want to use it to check the signature. This is achieved using
221 --load-signer instead of --load-trust. This will load one certificate
222 and it will be used to verify the signature in the OCSP response. It
223 will not check the Extended Key Usage bit.
224
225 $ ocsptool -e --load-signer ocsp-signer.pem --load-response ocsp-response.der
226
227 This approach is normally only relevant in two situations. The first
228 is when the OCSP response does not contain a copy of the signer cer‐
229 tificate, so the --load-trust code would fail. The second is if you
230 want to avoid the indirect mode where the OCSP response signer certifi‐
231 cate is signed by a trust anchor.
232
233 Real-world example
234
235 Here is an example of how to generate an OCSP request for a certificate
236 and to verify the response. For illustration we'll use the blog.josef‐
237 sson.org host, which (as of writing) uses a certificate from CACert.
238 First we'll use gnutls-cli to get a copy of the server certificate
239 chain. The server is not required to send this information, but this
240 particular one is configured to do so.
241
242 $ echo | gnutls-cli -p 443 blog.josefsson.org --save-cert chain.pem
243
244 The saved certificates normally contain a pointer to where the OCSP re‐
245 sponder is located, in the Authority Information Access Information ex‐
246 tension. For example, from certtool -i < chain.pem there is this in‐
247 formation:
248
249 Authority Information Access Information (not critical):
250 Access Method: 1.3.6.1.5.5.7.48.1 (id-ad-ocsp)
251 Access Location URI: https://ocsp.CAcert.org/
252
253 This means that ocsptool can discover the servers to contact over HTTP.
254 We can now request information on the chain certificates.
255
256 $ ocsptool --ask --load-chain chain.pem
257
258 The request is sent via HTTP to the OCSP server address found in the
259 certificates. It is possible to override the address of the OCSP server
260 as well as ask information on a particular certificate using
261 --load-cert and --load-issuer.
262
263 $ ocsptool --ask https://ocsp.CAcert.org/ --load-chain chain.pem
264
266 One of the following exit values will be returned:
267
268 0 (EXIT_SUCCESS)
269 Successful program execution.
270
271 1 (EXIT_FAILURE)
272 The operation failed or the command syntax was not valid.
273
275 certtool (1)
276
279 Copyright (C) 2020-2023 Free Software Foundation, and others all rights
280 reserved. This program is released under the terms of the GNU General
281 Public License, version 3 or later
282
284 Please send bug reports to: bugs@gnutls.org
285
286
287
2883.8.2 15 Nov 2023 ocsptool(1)