openssl-ocsp.pod.in 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. =pod
  2. {- OpenSSL::safe::output_do_not_edit_headers(); -}
  3. =head1 NAME
  4. openssl-ocsp - Online Certificate Status Protocol command
  5. =head1 SYNOPSIS
  6. =head2 OCSP Client
  7. B<openssl> B<ocsp>
  8. [B<-help>]
  9. [B<-out> I<file>]
  10. [B<-issuer> I<file>]
  11. [B<-cert> I<file>]
  12. [B<-no_certs>]
  13. [B<-serial> I<n>]
  14. [B<-signer> I<file>]
  15. [B<-signkey> I<file>]
  16. [B<-sign_other> I<file>]
  17. [B<-nonce>]
  18. [B<-no_nonce>]
  19. [B<-req_text>]
  20. [B<-resp_text>]
  21. [B<-text>]
  22. [B<-reqout> I<file>]
  23. [B<-respout> I<file>]
  24. [B<-reqin> I<file>]
  25. [B<-respin> I<file>]
  26. [B<-url> I<URL>]
  27. [B<-host> I<host>:I<port>]
  28. [B<-path>]
  29. [B<-proxy> I<[http[s]://][userinfo@]host[:port][/path]>]
  30. [B<-no_proxy> I<addresses>]
  31. [B<-header>]
  32. [B<-timeout> I<seconds>]
  33. [B<-VAfile> I<file>]
  34. [B<-validity_period> I<n>]
  35. [B<-status_age> I<n>]
  36. [B<-noverify>]
  37. [B<-verify_other> I<file>]
  38. [B<-trust_other>]
  39. [B<-no_intern>]
  40. [B<-no_signature_verify>]
  41. [B<-no_cert_verify>]
  42. [B<-no_chain>]
  43. [B<-no_cert_checks>]
  44. [B<-no_explicit>]
  45. [B<-port> I<num>]
  46. [B<-ignore_err>]
  47. =head2 OCSP Server
  48. B<openssl> B<ocsp>
  49. [B<-index> I<file>]
  50. [B<-CA> I<file>]
  51. [B<-rsigner> I<file>]
  52. [B<-rkey> I<file>]
  53. [B<-passin> I<arg>]
  54. [B<-rother> I<file>]
  55. [B<-rsigopt> I<nm>:I<v>]
  56. [B<-rmd> I<digest>]
  57. [B<-badsig>]
  58. [B<-resp_no_certs>]
  59. [B<-nmin> I<n>]
  60. [B<-ndays> I<n>]
  61. [B<-resp_key_id>]
  62. [B<-nrequest> I<n>]
  63. [B<-multi> I<process-count>]
  64. [B<-rcid> I<digest>]
  65. [B<-I<digest>>]
  66. {- $OpenSSL::safe::opt_trust_synopsis -}
  67. {- $OpenSSL::safe::opt_v_synopsis -}
  68. {- $OpenSSL::safe::opt_provider_synopsis -}
  69. =head1 DESCRIPTION
  70. The Online Certificate Status Protocol (OCSP) enables applications to
  71. determine the (revocation) state of an identified certificate (RFC 2560).
  72. This command performs many common OCSP tasks. It can be used
  73. to print out requests and responses, create requests and send queries
  74. to an OCSP responder and behave like a mini OCSP server itself.
  75. =head1 OPTIONS
  76. This command operates as either a client or a server.
  77. The options are described below, divided into those two modes.
  78. =head2 OCSP Client Options
  79. =over 4
  80. =item B<-help>
  81. Print out a usage message.
  82. =item B<-out> I<filename>
  83. specify output filename, default is standard output.
  84. =item B<-issuer> I<filename>
  85. This specifies the current issuer certificate.
  86. This option can be used multiple times.
  87. This option B<MUST> come before any B<-cert> options.
  88. =item B<-cert> I<filename>
  89. Add the certificate I<filename> to the request.
  90. This option can be used multiple times.
  91. The issuer certificate is taken from the previous B<-issuer> option,
  92. or an error occurs if no issuer certificate is specified.
  93. =item B<-no_certs>
  94. Don't include any certificates in signed request.
  95. =item B<-serial> I<num>
  96. Same as the B<-cert> option except the certificate with serial number
  97. B<num> is added to the request. The serial number is interpreted as a
  98. decimal integer unless preceded by C<0x>. Negative integers can also
  99. be specified by preceding the value by a C<-> sign.
  100. =item B<-signer> I<filename>, B<-signkey> I<filename>
  101. Sign the OCSP request using the certificate specified in the B<-signer>
  102. option and the private key specified by the B<-signkey> option. If
  103. the B<-signkey> option is not present then the private key is read
  104. from the same file as the certificate. If neither option is specified then
  105. the OCSP request is not signed.
  106. =item B<-sign_other> I<filename>
  107. Additional certificates to include in the signed request.
  108. The input can be in PEM, DER, or PKCS#12 format.
  109. =item B<-nonce>, B<-no_nonce>
  110. Add an OCSP nonce extension to a request or disable OCSP nonce addition.
  111. Normally if an OCSP request is input using the B<-reqin> option no
  112. nonce is added: using the B<-nonce> option will force addition of a nonce.
  113. If an OCSP request is being created (using B<-cert> and B<-serial> options)
  114. a nonce is automatically added specifying B<-no_nonce> overrides this.
  115. =item B<-req_text>, B<-resp_text>, B<-text>
  116. Print out the text form of the OCSP request, response or both respectively.
  117. =item B<-reqout> I<file>, B<-respout> I<file>
  118. Write out the DER encoded certificate request or response to I<file>.
  119. =item B<-reqin> I<file>, B<-respin> I<file>
  120. Read OCSP request or response file from I<file>. These option are ignored
  121. if OCSP request or response creation is implied by other options (for example
  122. with B<-serial>, B<-cert> and B<-host> options).
  123. =item B<-url> I<responder_url>
  124. Specify the responder URL. Both HTTP and HTTPS (SSL/TLS) URLs can be specified.
  125. The optional userinfo and fragment components are ignored.
  126. Any given query component is handled as part of the path component.
  127. =item B<-host> I<hostname>:I<port>, B<-path> I<pathname>
  128. If the B<-host> option is present then the OCSP request is sent to the host
  129. I<hostname> on port I<port>. The B<-path> option specifies the HTTP pathname
  130. to use or "/" by default. This is equivalent to specifying B<-url> with scheme
  131. http:// and the given hostname, port, and pathname.
  132. =item B<-proxy> I<[http[s]://][userinfo@]host[:port][/path]>
  133. The HTTP(S) proxy server to use for reaching the OCSP server unless B<-no_proxy>
  134. applies, see below.
  135. The proxy port defaults to 80 or 443 if the scheme is C<https>; apart from that
  136. the optional C<http://> or C<https://> prefix is ignored,
  137. as well as any userinfo and path components.
  138. Defaults to the environment variable C<http_proxy> if set, else C<HTTP_PROXY>
  139. in case no TLS is used, otherwise C<https_proxy> if set, else C<HTTPS_PROXY>.
  140. =item B<-no_proxy> I<addresses>
  141. List of IP addresses and/or DNS names of servers
  142. not to use an HTTP(S) proxy for, separated by commas and/or whitespace
  143. (where in the latter case the whole argument must be enclosed in "...").
  144. Default is from the environment variable C<no_proxy> if set, else C<NO_PROXY>.
  145. =item B<-header> I<name>=I<value>
  146. Adds the header I<name> with the specified I<value> to the OCSP request
  147. that is sent to the responder.
  148. This may be repeated.
  149. =item B<-timeout> I<seconds>
  150. Connection timeout to the OCSP responder in seconds.
  151. On POSIX systems, when running as an OCSP responder, this option also limits
  152. the time that the responder is willing to wait for the client request.
  153. This time is measured from the time the responder accepts the connection until
  154. the complete request is received.
  155. =item B<-verify_other> I<file>
  156. File or URI containing additional certificates to search
  157. when attempting to locate
  158. the OCSP response signing certificate. Some responders omit the actual signer's
  159. certificate from the response: this option can be used to supply the necessary
  160. certificate in such cases.
  161. The input can be in PEM, DER, or PKCS#12 format.
  162. =item B<-trust_other>
  163. The certificates specified by the B<-verify_other> option should be explicitly
  164. trusted and no additional checks will be performed on them. This is useful
  165. when the complete responder certificate chain is not available or trusting a
  166. root CA is not appropriate.
  167. =item B<-VAfile> I<file>
  168. File or URI containing explicitly trusted responder certificates.
  169. Equivalent to the B<-verify_other> and B<-trust_other> options.
  170. The input can be in PEM, DER, or PKCS#12 format.
  171. =item B<-noverify>
  172. Don't attempt to verify the OCSP response signature or the nonce
  173. values. This option will normally only be used for debugging since it
  174. disables all verification of the responders certificate.
  175. =item B<-no_intern>
  176. Ignore certificates contained in the OCSP response when searching for the
  177. signers certificate. With this option the signers certificate must be specified
  178. with either the B<-verify_other> or B<-VAfile> options.
  179. =item B<-no_signature_verify>
  180. Don't check the signature on the OCSP response. Since this option
  181. tolerates invalid signatures on OCSP responses it will normally only be
  182. used for testing purposes.
  183. =item B<-no_cert_verify>
  184. Don't verify the OCSP response signers certificate at all. Since this
  185. option allows the OCSP response to be signed by any certificate it should
  186. only be used for testing purposes.
  187. =item B<-no_chain>
  188. Do not use certificates in the response as additional untrusted CA
  189. certificates.
  190. =item B<-no_explicit>
  191. Do not explicitly trust the root CA if it is set to be trusted for OCSP signing.
  192. =item B<-no_cert_checks>
  193. Don't perform any additional checks on the OCSP response signers certificate.
  194. That is do not make any checks to see if the signers certificate is authorised
  195. to provide the necessary status information: as a result this option should
  196. only be used for testing purposes.
  197. =item B<-validity_period> I<nsec>, B<-status_age> I<age>
  198. These options specify the range of times, in seconds, which will be tolerated
  199. in an OCSP response. Each certificate status response includes a B<notBefore>
  200. time and an optional B<notAfter> time. The current time should fall between
  201. these two values, but the interval between the two times may be only a few
  202. seconds. In practice the OCSP responder and clients clocks may not be precisely
  203. synchronised and so such a check may fail. To avoid this the
  204. B<-validity_period> option can be used to specify an acceptable error range in
  205. seconds, the default value is 5 minutes.
  206. If the B<notAfter> time is omitted from a response then this means that new
  207. status information is immediately available. In this case the age of the
  208. B<notBefore> field is checked to see it is not older than I<age> seconds old.
  209. By default this additional check is not performed.
  210. =item B<-rcid> I<digest>
  211. This option sets the digest algorithm to use for certificate identification
  212. in the OCSP response. Any digest supported by the L<openssl-dgst(1)> command can
  213. be used. The default is the same digest algorithm used in the request.
  214. =item B<-I<digest>>
  215. This option sets digest algorithm to use for certificate identification in the
  216. OCSP request. Any digest supported by the OpenSSL B<dgst> command can be used.
  217. The default is SHA-1. This option may be used multiple times to specify the
  218. digest used by subsequent certificate identifiers.
  219. {- $OpenSSL::safe::opt_trust_item -}
  220. {- $OpenSSL::safe::opt_v_item -}
  221. {- $OpenSSL::safe::opt_provider_item -}
  222. =back
  223. =head2 OCSP Server Options
  224. =over 4
  225. =item B<-index> I<indexfile>
  226. The I<indexfile> parameter is the name of a text index file in B<ca>
  227. format containing certificate revocation information.
  228. If the B<-index> option is specified then this command switches to
  229. responder mode, otherwise it is in client mode. The request(s) the responder
  230. processes can be either specified on the command line (using B<-issuer>
  231. and B<-serial> options), supplied in a file (using the B<-reqin> option)
  232. or via external OCSP clients (if B<-port> or B<-url> is specified).
  233. If the B<-index> option is present then the B<-CA> and B<-rsigner> options
  234. must also be present.
  235. =item B<-CA> I<file>
  236. CA certificate corresponding to the revocation information in the index
  237. file given with B<-index>.
  238. The input can be in PEM, DER, or PKCS#12 format.
  239. =item B<-rsigner> I<file>
  240. The certificate to sign OCSP responses with.
  241. =item B<-rkey> I<file>
  242. The private key to sign OCSP responses with: if not present the file
  243. specified in the B<-rsigner> option is used.
  244. =item B<-passin> I<arg>
  245. The private key password source. For more information about the format of I<arg>
  246. see L<openssl-passphrase-options(1)>.
  247. =item B<-rother> I<file>
  248. Additional certificates to include in the OCSP response.
  249. The input can be in PEM, DER, or PKCS#12 format.
  250. =item B<-rsigopt> I<nm>:I<v>
  251. Pass options to the signature algorithm when signing OCSP responses.
  252. Names and values of these options are algorithm-specific.
  253. =item B<-rmd> I<digest>
  254. The digest to use when signing the response.
  255. =item B<-badsig>
  256. Corrupt the response signature before writing it; this can be useful
  257. for testing.
  258. =item B<-resp_no_certs>
  259. Don't include any certificates in the OCSP response.
  260. =item B<-resp_key_id>
  261. Identify the signer certificate using the key ID, default is to use the
  262. subject name.
  263. =item B<-port> I<portnum>
  264. Port to listen for OCSP requests on. The port may also be specified
  265. using the B<url> option.
  266. A C<0> argument indicates that any available port shall be chosen automatically.
  267. =item B<-ignore_err>
  268. Ignore malformed requests or responses: When acting as an OCSP client, retry if
  269. a malformed response is received. When acting as an OCSP responder, continue
  270. running instead of terminating upon receiving a malformed request.
  271. =item B<-nrequest> I<number>
  272. The OCSP server will exit after receiving I<number> requests, default unlimited.
  273. =item B<-multi> I<process-count>
  274. Run the specified number of OCSP responder child processes, with the parent
  275. process respawning child processes as needed.
  276. Child processes will detect changes in the CA index file and automatically
  277. reload it.
  278. When running as a responder B<-timeout> option is recommended to limit the time
  279. each child is willing to wait for the client's OCSP response.
  280. This option is available on POSIX systems (that support the fork() and other
  281. required unix system-calls).
  282. =item B<-nmin> I<minutes>, B<-ndays> I<days>
  283. Number of minutes or days when fresh revocation information is available:
  284. used in the B<nextUpdate> field. If neither option is present then the
  285. B<nextUpdate> field is omitted meaning fresh revocation information is
  286. immediately available.
  287. =back
  288. =head1 OCSP RESPONSE VERIFICATION
  289. OCSP Response follows the rules specified in RFC2560.
  290. Initially the OCSP responder certificate is located and the signature on
  291. the OCSP request checked using the responder certificate's public key.
  292. Then a normal certificate verify is performed on the OCSP responder certificate
  293. building up a certificate chain in the process. The locations of the trusted
  294. certificates used to build the chain can be specified by the B<-CAfile>,
  295. B<-CApath> or B<-CAstore> options or they will be looked for in the
  296. standard OpenSSL certificates directory.
  297. If the initial verify fails then the OCSP verify process halts with an
  298. error.
  299. Otherwise the issuing CA certificate in the request is compared to the OCSP
  300. responder certificate: if there is a match then the OCSP verify succeeds.
  301. Otherwise the OCSP responder certificate's CA is checked against the issuing
  302. CA certificate in the request. If there is a match and the OCSPSigning
  303. extended key usage is present in the OCSP responder certificate then the
  304. OCSP verify succeeds.
  305. Otherwise, if B<-no_explicit> is B<not> set the root CA of the OCSP responders
  306. CA is checked to see if it is trusted for OCSP signing. If it is the OCSP
  307. verify succeeds.
  308. If none of these checks is successful then the OCSP verify fails.
  309. What this effectively means if that if the OCSP responder certificate is
  310. authorised directly by the CA it is issuing revocation information about
  311. (and it is correctly configured) then verification will succeed.
  312. If the OCSP responder is a "global responder" which can give details about
  313. multiple CAs and has its own separate certificate chain then its root
  314. CA can be trusted for OCSP signing. For example:
  315. openssl x509 -in ocspCA.pem -addtrust OCSPSigning -out trustedCA.pem
  316. Alternatively the responder certificate itself can be explicitly trusted
  317. with the B<-VAfile> option.
  318. =head1 NOTES
  319. As noted, most of the verify options are for testing or debugging purposes.
  320. Normally only the B<-CApath>, B<-CAfile>, B<-CAstore> and (if the responder
  321. is a 'global VA') B<-VAfile> options need to be used.
  322. The OCSP server is only useful for test and demonstration purposes: it is
  323. not really usable as a full OCSP responder. It contains only a very
  324. simple HTTP request handling and can only handle the POST form of OCSP
  325. queries. It also handles requests serially meaning it cannot respond to
  326. new requests until it has processed the current one. The text index file
  327. format of revocation is also inefficient for large quantities of revocation
  328. data.
  329. It is possible to run this command in responder mode via a CGI
  330. script using the B<-reqin> and B<-respout> options.
  331. =head1 EXAMPLES
  332. Create an OCSP request and write it to a file:
  333. openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem -reqout req.der
  334. Send a query to an OCSP responder with URL http://ocsp.myhost.com/ save the
  335. response to a file, print it out in text form, and verify the response:
  336. openssl ocsp -issuer issuer.pem -cert c1.pem -cert c2.pem \
  337. -url http://ocsp.myhost.com/ -resp_text -respout resp.der
  338. Read in an OCSP response and print out text form:
  339. openssl ocsp -respin resp.der -text -noverify
  340. OCSP server on port 8888 using a standard B<ca> configuration, and a separate
  341. responder certificate. All requests and responses are printed to a file.
  342. openssl ocsp -index demoCA/index.txt -port 8888 -rsigner rcert.pem -CA demoCA/cacert.pem
  343. -text -out log.txt
  344. As above but exit after processing one request:
  345. openssl ocsp -index demoCA/index.txt -port 8888 -rsigner rcert.pem -CA demoCA/cacert.pem
  346. -nrequest 1
  347. Query status information using an internally generated request:
  348. openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA demoCA/cacert.pem
  349. -issuer demoCA/cacert.pem -serial 1
  350. Query status information using request read from a file, and write the response
  351. to a second file.
  352. openssl ocsp -index demoCA/index.txt -rsigner rcert.pem -CA demoCA/cacert.pem
  353. -reqin req.der -respout resp.der
  354. =head1 HISTORY
  355. The -no_alt_chains option was added in OpenSSL 1.1.0.
  356. =head1 COPYRIGHT
  357. Copyright 2001-2022 The OpenSSL Project Authors. All Rights Reserved.
  358. Licensed under the Apache License 2.0 (the "License"). You may not use
  359. this file except in compliance with the License. You can obtain a copy
  360. in the file LICENSE in the source distribution or at
  361. L<https://www.openssl.org/source/license.html>.
  362. =cut