ocsp.pod 16 KB

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