1b077aed3SPierre Pronchery=pod
2b077aed3SPierre Pronchery
3b077aed3SPierre Pronchery=head1 NAME
4b077aed3SPierre Pronchery
5b077aed3SPierre ProncheryOSSL_CMP_CTX_new,
6b077aed3SPierre ProncheryOSSL_CMP_CTX_free,
7b077aed3SPierre ProncheryOSSL_CMP_CTX_reinit,
8b077aed3SPierre ProncheryOSSL_CMP_CTX_set_option,
9b077aed3SPierre ProncheryOSSL_CMP_CTX_get_option,
10b077aed3SPierre ProncheryOSSL_CMP_CTX_set_log_cb,
11b077aed3SPierre ProncheryOSSL_CMP_CTX_set_log_verbosity,
12b077aed3SPierre ProncheryOSSL_CMP_CTX_print_errors,
13b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_serverPath,
14b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_server,
15b077aed3SPierre ProncheryOSSL_CMP_CTX_set_serverPort,
16b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_proxy,
17b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_no_proxy,
18b077aed3SPierre ProncheryOSSL_CMP_CTX_set_http_cb,
19b077aed3SPierre ProncheryOSSL_CMP_CTX_set_http_cb_arg,
20b077aed3SPierre ProncheryOSSL_CMP_CTX_get_http_cb_arg,
21b077aed3SPierre ProncheryOSSL_CMP_transfer_cb_t,
22b077aed3SPierre ProncheryOSSL_CMP_CTX_set_transfer_cb,
23b077aed3SPierre ProncheryOSSL_CMP_CTX_set_transfer_cb_arg,
24b077aed3SPierre ProncheryOSSL_CMP_CTX_get_transfer_cb_arg,
25b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_srvCert,
26b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_expected_sender,
27b077aed3SPierre ProncheryOSSL_CMP_CTX_set0_trustedStore,
28b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_trustedStore,
29b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_untrusted,
30b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_untrusted,
31b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_cert,
32b077aed3SPierre ProncheryOSSL_CMP_CTX_build_cert_chain,
33b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_pkey,
34b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_referenceValue,
35b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_secretValue,
36b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_recipient,
37b077aed3SPierre ProncheryOSSL_CMP_CTX_push0_geninfo_ITAV,
38b077aed3SPierre ProncheryOSSL_CMP_CTX_reset_geninfo_ITAVs,
39b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_extraCertsOut,
40b077aed3SPierre ProncheryOSSL_CMP_CTX_set0_newPkey,
41b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_newPkey,
42b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_issuer,
43b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_subjectName,
44b077aed3SPierre ProncheryOSSL_CMP_CTX_push1_subjectAltName,
45b077aed3SPierre ProncheryOSSL_CMP_CTX_set0_reqExtensions,
46b077aed3SPierre ProncheryOSSL_CMP_CTX_reqExtensions_have_SAN,
47b077aed3SPierre ProncheryOSSL_CMP_CTX_push0_policy,
48b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_oldCert,
49b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_p10CSR,
50b077aed3SPierre ProncheryOSSL_CMP_CTX_push0_genm_ITAV,
51b077aed3SPierre ProncheryOSSL_CMP_certConf_cb_t,
52b077aed3SPierre ProncheryOSSL_CMP_certConf_cb,
53b077aed3SPierre ProncheryOSSL_CMP_CTX_set_certConf_cb,
54b077aed3SPierre ProncheryOSSL_CMP_CTX_set_certConf_cb_arg,
55b077aed3SPierre ProncheryOSSL_CMP_CTX_get_certConf_cb_arg,
56b077aed3SPierre ProncheryOSSL_CMP_CTX_get_status,
57b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_statusString,
58b077aed3SPierre ProncheryOSSL_CMP_CTX_get_failInfoCode,
59b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_newCert,
60b077aed3SPierre ProncheryOSSL_CMP_CTX_get1_newChain,
61b077aed3SPierre ProncheryOSSL_CMP_CTX_get1_caPubs,
62b077aed3SPierre ProncheryOSSL_CMP_CTX_get1_extraCertsIn,
63b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_transactionID,
64b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_senderNonce
65b077aed3SPierre Pronchery- functions for managing the CMP client context data structure
66b077aed3SPierre Pronchery
67b077aed3SPierre Pronchery=head1 SYNOPSIS
68b077aed3SPierre Pronchery
69b077aed3SPierre Pronchery #include <openssl/cmp.h>
70b077aed3SPierre Pronchery
71b077aed3SPierre Pronchery OSSL_CMP_CTX *OSSL_CMP_CTX_new(OSSL_LIB_CTX *libctx, const char *propq);
72b077aed3SPierre Pronchery void OSSL_CMP_CTX_free(OSSL_CMP_CTX *ctx);
73b077aed3SPierre Pronchery int OSSL_CMP_CTX_reinit(OSSL_CMP_CTX *ctx);
74b077aed3SPierre Pronchery int OSSL_CMP_CTX_set_option(OSSL_CMP_CTX *ctx, int opt, int val);
75b077aed3SPierre Pronchery int OSSL_CMP_CTX_get_option(const OSSL_CMP_CTX *ctx, int opt);
76b077aed3SPierre Pronchery
77b077aed3SPierre Pronchery /* logging and error reporting: */
78b077aed3SPierre Pronchery int OSSL_CMP_CTX_set_log_cb(OSSL_CMP_CTX *ctx, OSSL_CMP_log_cb_t cb);
79b077aed3SPierre Pronchery #define OSSL_CMP_CTX_set_log_verbosity(ctx, level)
80b077aed3SPierre Pronchery void OSSL_CMP_CTX_print_errors(const OSSL_CMP_CTX *ctx);
81b077aed3SPierre Pronchery
82b077aed3SPierre Pronchery /* message transfer: */
83b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_serverPath(OSSL_CMP_CTX *ctx, const char *path);
84b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_server(OSSL_CMP_CTX *ctx, const char *address);
85b077aed3SPierre Pronchery int OSSL_CMP_CTX_set_serverPort(OSSL_CMP_CTX *ctx, int port);
86b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_proxy(OSSL_CMP_CTX *ctx, const char *name);
87b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_no_proxy(OSSL_CMP_CTX *ctx, const char *names);
88b077aed3SPierre Pronchery int OSSL_CMP_CTX_set_http_cb(OSSL_CMP_CTX *ctx, HTTP_bio_cb_t cb);
89b077aed3SPierre Pronchery int OSSL_CMP_CTX_set_http_cb_arg(OSSL_CMP_CTX *ctx, void *arg);
90b077aed3SPierre Pronchery void *OSSL_CMP_CTX_get_http_cb_arg(const OSSL_CMP_CTX *ctx);
91b077aed3SPierre Pronchery typedef OSSL_CMP_MSG *(*OSSL_CMP_transfer_cb_t)(OSSL_CMP_CTX *ctx,
92b077aed3SPierre Pronchery                                                 const OSSL_CMP_MSG *req);
93b077aed3SPierre Pronchery int OSSL_CMP_CTX_set_transfer_cb(OSSL_CMP_CTX *ctx,
94b077aed3SPierre Pronchery                                  OSSL_CMP_transfer_cb_t cb);
95b077aed3SPierre Pronchery int OSSL_CMP_CTX_set_transfer_cb_arg(OSSL_CMP_CTX *ctx, void *arg);
96b077aed3SPierre Pronchery void *OSSL_CMP_CTX_get_transfer_cb_arg(const OSSL_CMP_CTX *ctx);
97b077aed3SPierre Pronchery
98b077aed3SPierre Pronchery /* server authentication: */
99b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_srvCert(OSSL_CMP_CTX *ctx, X509 *cert);
100b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_expected_sender(OSSL_CMP_CTX *ctx,
101b077aed3SPierre Pronchery                                      const X509_NAME *name);
102b077aed3SPierre Pronchery int OSSL_CMP_CTX_set0_trustedStore(OSSL_CMP_CTX *ctx, X509_STORE *store);
103b077aed3SPierre Pronchery X509_STORE *OSSL_CMP_CTX_get0_trustedStore(const OSSL_CMP_CTX *ctx);
104b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_untrusted(OSSL_CMP_CTX *ctx, STACK_OF(X509) *certs);
105b077aed3SPierre Pronchery STACK_OF(X509) *OSSL_CMP_CTX_get0_untrusted(const OSSL_CMP_CTX *ctx);
106b077aed3SPierre Pronchery
107b077aed3SPierre Pronchery /* client authentication: */
108b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_cert(OSSL_CMP_CTX *ctx, X509 *cert);
109b077aed3SPierre Pronchery int OSSL_CMP_CTX_build_cert_chain(OSSL_CMP_CTX *ctx, X509_STORE *own_trusted,
110b077aed3SPierre Pronchery                                   STACK_OF(X509) *candidates);
111b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_pkey(OSSL_CMP_CTX *ctx, EVP_PKEY *pkey);
112b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_referenceValue(OSSL_CMP_CTX *ctx,
113b077aed3SPierre Pronchery                                      const unsigned char *ref, int len);
114b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_secretValue(OSSL_CMP_CTX *ctx,
115b077aed3SPierre Pronchery                                   const unsigned char *sec, int len);
116b077aed3SPierre Pronchery
117b077aed3SPierre Pronchery /* CMP message header and extra certificates: */
118b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_recipient(OSSL_CMP_CTX *ctx, const X509_NAME *name);
119b077aed3SPierre Pronchery int OSSL_CMP_CTX_push0_geninfo_ITAV(OSSL_CMP_CTX *ctx, OSSL_CMP_ITAV *itav);
120b077aed3SPierre Pronchery int OSSL_CMP_CTX_reset_geninfo_ITAVs(OSSL_CMP_CTX *ctx);
121b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_extraCertsOut(OSSL_CMP_CTX *ctx,
122b077aed3SPierre Pronchery                                     STACK_OF(X509) *extraCertsOut);
123b077aed3SPierre Pronchery
124b077aed3SPierre Pronchery /* certificate template: */
125b077aed3SPierre Pronchery int OSSL_CMP_CTX_set0_newPkey(OSSL_CMP_CTX *ctx, int priv, EVP_PKEY *pkey);
126b077aed3SPierre Pronchery EVP_PKEY *OSSL_CMP_CTX_get0_newPkey(const OSSL_CMP_CTX *ctx, int priv);
127b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_issuer(OSSL_CMP_CTX *ctx, const X509_NAME *name);
128b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_subjectName(OSSL_CMP_CTX *ctx, const X509_NAME *name);
129b077aed3SPierre Pronchery int OSSL_CMP_CTX_push1_subjectAltName(OSSL_CMP_CTX *ctx,
130b077aed3SPierre Pronchery                                       const GENERAL_NAME *name);
131b077aed3SPierre Pronchery int OSSL_CMP_CTX_set0_reqExtensions(OSSL_CMP_CTX *ctx, X509_EXTENSIONS *exts);
132b077aed3SPierre Pronchery int OSSL_CMP_CTX_reqExtensions_have_SAN(OSSL_CMP_CTX *ctx);
133b077aed3SPierre Pronchery int OSSL_CMP_CTX_push0_policy(OSSL_CMP_CTX *ctx, POLICYINFO *pinfo);
134b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_oldCert(OSSL_CMP_CTX *ctx, X509 *cert);
135b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_p10CSR(OSSL_CMP_CTX *ctx, const X509_REQ *csr);
136b077aed3SPierre Pronchery
137b077aed3SPierre Pronchery /* misc body contents: */
138b077aed3SPierre Pronchery int OSSL_CMP_CTX_push0_genm_ITAV(OSSL_CMP_CTX *ctx, OSSL_CMP_ITAV *itav);
139b077aed3SPierre Pronchery
140b077aed3SPierre Pronchery /* certificate confirmation: */
141b077aed3SPierre Pronchery typedef int (*OSSL_CMP_certConf_cb_t)(OSSL_CMP_CTX *ctx, X509 *cert,
142b077aed3SPierre Pronchery                                       int fail_info, const char **txt);
143b077aed3SPierre Pronchery int OSSL_CMP_certConf_cb(OSSL_CMP_CTX *ctx, X509 *cert, int fail_info,
144b077aed3SPierre Pronchery                          const char **text);
145b077aed3SPierre Pronchery int OSSL_CMP_CTX_set_certConf_cb(OSSL_CMP_CTX *ctx, OSSL_CMP_certConf_cb_t cb);
146b077aed3SPierre Pronchery int OSSL_CMP_CTX_set_certConf_cb_arg(OSSL_CMP_CTX *ctx, void *arg);
147b077aed3SPierre Pronchery void *OSSL_CMP_CTX_get_certConf_cb_arg(const OSSL_CMP_CTX *ctx);
148b077aed3SPierre Pronchery
149b077aed3SPierre Pronchery /* result fetching: */
150b077aed3SPierre Pronchery int OSSL_CMP_CTX_get_status(const OSSL_CMP_CTX *ctx);
151b077aed3SPierre Pronchery OSSL_CMP_PKIFREETEXT *OSSL_CMP_CTX_get0_statusString(const OSSL_CMP_CTX *ctx);
152b077aed3SPierre Pronchery int OSSL_CMP_CTX_get_failInfoCode(const OSSL_CMP_CTX *ctx);
153b077aed3SPierre Pronchery
154b077aed3SPierre Pronchery X509 *OSSL_CMP_CTX_get0_newCert(const OSSL_CMP_CTX *ctx);
155b077aed3SPierre Pronchery STACK_OF(X509) *OSSL_CMP_CTX_get1_newChain(const OSSL_CMP_CTX *ctx);
156b077aed3SPierre Pronchery STACK_OF(X509) *OSSL_CMP_CTX_get1_caPubs(const OSSL_CMP_CTX *ctx);
157b077aed3SPierre Pronchery STACK_OF(X509) *OSSL_CMP_CTX_get1_extraCertsIn(const OSSL_CMP_CTX *ctx);
158b077aed3SPierre Pronchery
159b077aed3SPierre Pronchery /* for testing and debugging purposes: */
160b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_transactionID(OSSL_CMP_CTX *ctx,
161b077aed3SPierre Pronchery                                     const ASN1_OCTET_STRING *id);
162b077aed3SPierre Pronchery int OSSL_CMP_CTX_set1_senderNonce(OSSL_CMP_CTX *ctx,
163b077aed3SPierre Pronchery                                   const ASN1_OCTET_STRING *nonce);
164b077aed3SPierre Pronchery
165b077aed3SPierre Pronchery=head1 DESCRIPTION
166b077aed3SPierre Pronchery
167b077aed3SPierre ProncheryThis is the context API for using CMP (Certificate Management Protocol) with
168b077aed3SPierre ProncheryOpenSSL.
169b077aed3SPierre Pronchery
170b077aed3SPierre ProncheryOSSL_CMP_CTX_new() allocates an B<OSSL_CMP_CTX> structure associated with
171b077aed3SPierre Proncherythe library context I<libctx> and property query string I<propq>,
172b077aed3SPierre Proncheryboth of which may be NULL to select the defaults.
173b077aed3SPierre ProncheryIt initializes the remaining fields to their default values - for instance,
174b077aed3SPierre Proncherythe logging verbosity is set to OSSL_CMP_LOG_INFO,
175b077aed3SPierre Proncherythe message timeout is set to 120 seconds,
176b077aed3SPierre Proncheryand the proof-of-possession method is set to OSSL_CRMF_POPO_SIGNATURE.
177b077aed3SPierre Pronchery
178b077aed3SPierre ProncheryOSSL_CMP_CTX_free() deallocates an OSSL_CMP_CTX structure.
179b077aed3SPierre Pronchery
180b077aed3SPierre ProncheryOSSL_CMP_CTX_reinit() prepares the given I<ctx> for a further transaction by
181b077aed3SPierre Proncheryclearing the internal CMP transaction (aka session) status, PKIStatusInfo,
182b077aed3SPierre Proncheryand any previous results (newCert, newChain, caPubs, and extraCertsIn)
183b077aed3SPierre Proncheryfrom the last executed transaction.
184b077aed3SPierre ProncheryIt also clears any ITAVs that were added by OSSL_CMP_CTX_push0_genm_ITAV().
185*6f1af0d7SPierre ProncheryAll other field values (i.e., CMP options) are retained for potential reuse.
186b077aed3SPierre Pronchery
187b077aed3SPierre ProncheryOSSL_CMP_CTX_set_option() sets the given value for the given option
188b077aed3SPierre Pronchery(e.g., OSSL_CMP_OPT_IMPLICIT_CONFIRM) in the given OSSL_CMP_CTX structure.
189b077aed3SPierre Pronchery
190b077aed3SPierre ProncheryThe following options can be set:
191b077aed3SPierre Pronchery
192b077aed3SPierre Pronchery=over 4
193b077aed3SPierre Pronchery
194b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_LOG_VERBOSITY>
195b077aed3SPierre Pronchery
196b077aed3SPierre Pronchery        The level of severity needed for actually outputting log messages
197b077aed3SPierre Pronchery        due to errors, warnings, general info, debugging, etc.
198b077aed3SPierre Pronchery        Default is OSSL_CMP_LOG_INFO. See also L<OSSL_CMP_log_open(3)>.
199b077aed3SPierre Pronchery
200b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_KEEP_ALIVE>
201b077aed3SPierre Pronchery
202b077aed3SPierre Pronchery        If the given value is 0 then HTTP connections are not kept open
203b077aed3SPierre Pronchery        after receiving a response, which is the default behavior for HTTP 1.0.
204b077aed3SPierre Pronchery        If the value is 1 or 2 then persistent connections are requested.
205b077aed3SPierre Pronchery        If the value is 2 then persistent connections are required,
206b077aed3SPierre Pronchery        i.e., in case the server does not grant them an error occurs.
207b077aed3SPierre Pronchery        The default value is 1: prefer to keep the connection open.
208b077aed3SPierre Pronchery
209b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_MSG_TIMEOUT>
210b077aed3SPierre Pronchery
211b077aed3SPierre Pronchery        Number of seconds a CMP request-response message round trip
212b077aed3SPierre Pronchery        is allowed to take before a timeout error is returned.
213b077aed3SPierre Pronchery        A value <= 0 means no limitation (waiting indefinitely).
214b077aed3SPierre Pronchery        Default is to use the B<OSSL_CMP_OPT_TOTAL_TIMEOUT> setting.
215b077aed3SPierre Pronchery
216b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_TOTAL_TIMEOUT>
217b077aed3SPierre Pronchery
218b077aed3SPierre Pronchery        Maximum total number of seconds a transaction may take,
219b077aed3SPierre Pronchery        including polling etc.
220b077aed3SPierre Pronchery        A value <= 0 means no limitation (waiting indefinitely).
221b077aed3SPierre Pronchery        Default is 0.
222b077aed3SPierre Pronchery
223b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_VALIDITY_DAYS>
224b077aed3SPierre Pronchery
225b077aed3SPierre Pronchery        Number of days new certificates are asked to be valid for.
226b077aed3SPierre Pronchery
227b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_SUBJECTALTNAME_NODEFAULT>
228b077aed3SPierre Pronchery
229b077aed3SPierre Pronchery        Do not take default Subject Alternative Names
230b077aed3SPierre Pronchery        from the reference certificate.
231b077aed3SPierre Pronchery
232b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_SUBJECTALTNAME_CRITICAL>
233b077aed3SPierre Pronchery
234b077aed3SPierre Pronchery        Demand that the given Subject Alternative Names are flagged as critical.
235b077aed3SPierre Pronchery
236b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_POLICIES_CRITICAL>
237b077aed3SPierre Pronchery
238b077aed3SPierre Pronchery        Demand that the given policies are flagged as critical.
239b077aed3SPierre Pronchery
240b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_POPO_METHOD>
241b077aed3SPierre Pronchery
242b077aed3SPierre Pronchery        Select the proof of possession method to use. Possible values are:
243b077aed3SPierre Pronchery
244b077aed3SPierre Pronchery            OSSL_CRMF_POPO_NONE       - ProofOfPossession field omitted
245b077aed3SPierre Pronchery            OSSL_CRMF_POPO_RAVERIFIED - assert that the RA has already
246b077aed3SPierre Pronchery                                        verified the PoPo
247b077aed3SPierre Pronchery            OSSL_CRMF_POPO_SIGNATURE  - sign a value with private key,
248b077aed3SPierre Pronchery                                        which is the default.
249b077aed3SPierre Pronchery            OSSL_CRMF_POPO_KEYENC     - decrypt the encrypted certificate
250b077aed3SPierre Pronchery                                        ("indirect method")
251b077aed3SPierre Pronchery
252b077aed3SPierre Pronchery        Note that a signature-based POPO can only be produced if a private key
253b077aed3SPierre Pronchery        is provided as the newPkey or client's pkey component of the CMP context.
254b077aed3SPierre Pronchery
255b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_DIGEST_ALGNID>
256b077aed3SPierre Pronchery
257b077aed3SPierre Pronchery        The NID of the digest algorithm to be used in RFC 4210's MSG_SIG_ALG
258b077aed3SPierre Pronchery        for signature-based message protection and Proof-of-Possession (POPO).
259b077aed3SPierre Pronchery        Default is SHA256.
260b077aed3SPierre Pronchery
261b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_OWF_ALGNID>
262b077aed3SPierre Pronchery        The NID of the digest algorithm to be used as one-way function (OWF)
263*6f1af0d7SPierre Pronchery        for MAC-based message protection with password-based MAC (PBM).
264*6f1af0d7SPierre Pronchery        See RFC 4210 section 5.1.3.1 for details.
265b077aed3SPierre Pronchery        Default is SHA256.
266b077aed3SPierre Pronchery
267b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_MAC_ALGNID>
268*6f1af0d7SPierre Pronchery        The NID of the MAC algorithm to be used for message protection with PBM.
269b077aed3SPierre Pronchery        Default is HMAC-SHA1 as per RFC 4210.
270b077aed3SPierre Pronchery
271b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_REVOCATION_REASON>
272b077aed3SPierre Pronchery
273b077aed3SPierre Pronchery        The reason code to be included in a Revocation Request (RR);
274b077aed3SPierre Pronchery        values: 0..10 (RFC 5210, 5.3.1) or -1 for none, which is the default.
275b077aed3SPierre Pronchery
276b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_IMPLICIT_CONFIRM>
277b077aed3SPierre Pronchery
278b077aed3SPierre Pronchery        Request server to enable implicit confirm mode, where the client
279b077aed3SPierre Pronchery        does not need to send confirmation upon receiving the
280b077aed3SPierre Pronchery        certificate. If the server does not enable implicit confirmation
281b077aed3SPierre Pronchery        in the return message, then confirmation is sent anyway.
282b077aed3SPierre Pronchery
283b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_DISABLE_CONFIRM>
284b077aed3SPierre Pronchery
285b077aed3SPierre Pronchery        Do not confirm enrolled certificates, to cope with broken servers
286b077aed3SPierre Pronchery        not supporting implicit confirmation correctly.
287b077aed3SPierre ProncheryB<WARNING:> This setting leads to unspecified behavior and it is meant
288b077aed3SPierre Proncheryexclusively to allow interoperability with server implementations violating
289b077aed3SPierre ProncheryRFC 4210.
290b077aed3SPierre Pronchery
291b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_UNPROTECTED_SEND>
292b077aed3SPierre Pronchery
293b077aed3SPierre Pronchery        Send request or response messages without CMP-level protection.
294b077aed3SPierre Pronchery
295b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_UNPROTECTED_ERRORS>
296b077aed3SPierre Pronchery
297b077aed3SPierre Pronchery        Accept unprotected error responses which are either explicitly
298b077aed3SPierre Pronchery        unprotected or where protection verification failed. Applies to regular
299b077aed3SPierre Pronchery        error messages as well as certificate responses (IP/CP/KUP) and
300b077aed3SPierre Pronchery        revocation responses (RP) with rejection.
301b077aed3SPierre ProncheryB<WARNING:> This setting leads to unspecified behavior and it is meant
302b077aed3SPierre Proncheryexclusively to allow interoperability with server implementations violating
303b077aed3SPierre ProncheryRFC 4210.
304b077aed3SPierre Pronchery
305b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_IGNORE_KEYUSAGE>
306b077aed3SPierre Pronchery
307b077aed3SPierre Pronchery        Ignore key usage restrictions in the signer's certificate when
308b077aed3SPierre Pronchery        validating signature-based protection in received CMP messages.
309b077aed3SPierre Pronchery        Else, 'digitalSignature' must be allowed by CMP signer certificates.
310b077aed3SPierre Pronchery
311b077aed3SPierre Pronchery=item B<OSSL_CMP_OPT_PERMIT_TA_IN_EXTRACERTS_FOR_IR>
312b077aed3SPierre Pronchery
313b077aed3SPierre Pronchery        Allow retrieving a trust anchor from extraCerts and using that
314b077aed3SPierre Pronchery        to validate the certificate chain of an IP message.
315b077aed3SPierre Pronchery
316b077aed3SPierre Pronchery=back
317b077aed3SPierre Pronchery
318b077aed3SPierre ProncheryOSSL_CMP_CTX_get_option() reads the current value of the given option
319b077aed3SPierre Pronchery(e.g., OSSL_CMP_OPT_IMPLICIT_CONFIRM) from the given OSSL_CMP_CTX structure.
320b077aed3SPierre Pronchery
321b077aed3SPierre ProncheryOSSL_CMP_CTX_set_log_cb() sets in I<ctx> the callback function I<cb>
322b077aed3SPierre Proncheryfor handling error queue entries and logging messages.
323b077aed3SPierre ProncheryWhen I<cb> is NULL errors are printed to STDERR (if available, else ignored)
324b077aed3SPierre Proncheryany log messages are ignored.
325b077aed3SPierre ProncheryAlternatively, L<OSSL_CMP_log_open(3)> may be used to direct logging to STDOUT.
326b077aed3SPierre Pronchery
327b077aed3SPierre ProncheryOSSL_CMP_CTX_set_log_verbosity() is a macro setting the
328b077aed3SPierre ProncheryOSSL_CMP_OPT_LOG_VERBOSITY context option to the given level.
329b077aed3SPierre Pronchery
330b077aed3SPierre ProncheryOSSL_CMP_CTX_print_errors() outputs any entries in the OpenSSL error queue. It
331b077aed3SPierre Proncheryis similar to L<ERR_print_errors_cb(3)> but uses the CMP log callback function
332b077aed3SPierre Proncheryif set in the I<ctx> for uniformity with CMP logging if given. Otherwise it uses
333b077aed3SPierre ProncheryL<ERR_print_errors(3)> to print to STDERR (unless OPENSSL_NO_STDIO is defined).
334b077aed3SPierre Pronchery
335b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_serverPath() sets the HTTP path of the CMP server on the host,
336b077aed3SPierre Proncheryalso known as "CMP alias".
337b077aed3SPierre ProncheryThe default is C</>.
338b077aed3SPierre Pronchery
339b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_server() sets the given server I<address>
340b077aed3SPierre Pronchery(which may be a hostname or IP address or NULL) in the given I<ctx>.
341b077aed3SPierre Pronchery
342b077aed3SPierre ProncheryOSSL_CMP_CTX_set_serverPort() sets the port of the CMP server to connect to.
343b077aed3SPierre ProncheryIf not used or the I<port> argument is 0
344b077aed3SPierre Proncherythe default port applies, which is 80 for HTTP and 443 for HTTPS.
345b077aed3SPierre Pronchery
346b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_proxy() sets the HTTP proxy to be used for connecting to
347b077aed3SPierre Proncherythe given CMP server unless overruled by any "no_proxy" settings (see below).
348b077aed3SPierre ProncheryIf TLS is not used this defaults to the value of
349b077aed3SPierre Proncherythe environment variable C<http_proxy> if set, else C<HTTP_PROXY>.
350b077aed3SPierre ProncheryOtherwise defaults to the value of C<https_proxy> if set, else C<HTTPS_PROXY>.
351b077aed3SPierre ProncheryAn empty proxy string specifies not to use a proxy.
352b077aed3SPierre ProncheryElse the format is C<[http[s]://]address[:port][/path]>,
353b077aed3SPierre Proncherywhere any path given is ignored.
354b077aed3SPierre ProncheryThe default port number is 80, or 443 in case C<https:> is given.
355b077aed3SPierre Pronchery
356b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_no_proxy() sets the list of server hostnames not to use
357b077aed3SPierre Proncheryan HTTP proxy for. The names may be separated by commas and/or whitespace.
358b077aed3SPierre ProncheryDefaults to the environment variable C<no_proxy> if set, else C<NO_PROXY>.
359b077aed3SPierre Pronchery
360b077aed3SPierre ProncheryOSSL_CMP_CTX_set_http_cb() sets the optional BIO connect/disconnect callback
361b077aed3SPierre Proncheryfunction, which has the prototype
362b077aed3SPierre Pronchery
363b077aed3SPierre Pronchery typedef BIO *(*HTTP_bio_cb_t) (BIO *bio, void *ctx, int connect, int detail);
364b077aed3SPierre Pronchery
365b077aed3SPierre ProncheryThe callback may modify the I<bio> provided by L<OSSL_CMP_MSG_http_perform(3)>,
366b077aed3SPierre Proncherywhereby it may make use of a custom defined argument I<ctx>
367b077aed3SPierre Proncherystored in the OSSL_CMP_CTX by means of OSSL_CMP_CTX_set_http_cb_arg().
368b077aed3SPierre ProncheryDuring connection establishment, just after calling BIO_do_connect_retry(),
369b077aed3SPierre Proncherythe function is invoked with the I<connect> argument being 1 and the I<detail>
370b077aed3SPierre Proncheryargument being 1 if HTTPS is requested, i.e., SSL/TLS should be enabled. On
371b077aed3SPierre Proncherydisconnect I<connect> is 0 and I<detail> is 1 in case no error occurred, else 0.
372b077aed3SPierre ProncheryFor instance, on connect the function may prepend a TLS BIO to implement HTTPS;
373b077aed3SPierre Proncheryafter disconnect it may do some diagnostic output and/or specific cleanup.
374b077aed3SPierre ProncheryThe function should return NULL to indicate failure.
375b077aed3SPierre ProncheryAfter disconnect the modified BIO will be deallocated using BIO_free_all().
376b077aed3SPierre Pronchery
377b077aed3SPierre ProncheryOSSL_CMP_CTX_set_http_cb_arg() sets an argument, respectively a pointer to
378b077aed3SPierre Proncherya structure containing arguments,
379b077aed3SPierre Proncheryoptionally to be used by the http connect/disconnect callback function.
380b077aed3SPierre ProncheryI<arg> is not consumed, and it must therefore explicitly be freed when not
381b077aed3SPierre Proncheryneeded any more. I<arg> may be NULL to clear the entry.
382b077aed3SPierre Pronchery
383b077aed3SPierre ProncheryOSSL_CMP_CTX_get_http_cb_arg() gets the argument, respectively the pointer to a
384b077aed3SPierre Proncherystructure containing arguments, previously set by
385b077aed3SPierre ProncheryOSSL_CMP_CTX_set_http_cb_arg() or NULL if unset.
386b077aed3SPierre Pronchery
387b077aed3SPierre ProncheryOSSL_CMP_CTX_set_transfer_cb() sets the message transfer callback function,
388b077aed3SPierre Proncherywhich has the type
389b077aed3SPierre Pronchery
390b077aed3SPierre Pronchery typedef OSSL_CMP_MSG *(*OSSL_CMP_transfer_cb_t) (OSSL_CMP_CTX *ctx,
391b077aed3SPierre Pronchery                                                  const OSSL_CMP_MSG *req);
392b077aed3SPierre Pronchery
393b077aed3SPierre ProncheryReturns 1 on success, 0 on error.
394b077aed3SPierre Pronchery
395b077aed3SPierre ProncheryDefault is NULL, which implies the use of L<OSSL_CMP_MSG_http_perform(3)>.
396b077aed3SPierre ProncheryThe callback should send the CMP request message it obtains via the I<req>
397b077aed3SPierre Proncheryparameter and on success return the response, else it must return NULL.
398b077aed3SPierre ProncheryThe transfer callback may make use of a custom defined argument stored in
399b077aed3SPierre Proncherythe ctx by means of OSSL_CMP_CTX_set_transfer_cb_arg(), which may be retrieved
400b077aed3SPierre Proncheryagain through OSSL_CMP_CTX_get_transfer_cb_arg().
401b077aed3SPierre Pronchery
402b077aed3SPierre ProncheryOSSL_CMP_CTX_set_transfer_cb_arg() sets an argument, respectively a pointer to a
403b077aed3SPierre Proncherystructure containing arguments, optionally to be used by the transfer callback.
404b077aed3SPierre ProncheryI<arg> is not consumed, and it must therefore explicitly be freed when not
405b077aed3SPierre Proncheryneeded any more. I<arg> may be NULL to clear the entry.
406b077aed3SPierre Pronchery
407b077aed3SPierre ProncheryOSSL_CMP_CTX_get_transfer_cb_arg() gets the argument, respectively the pointer
408b077aed3SPierre Proncheryto a structure containing arguments, previously set by
409b077aed3SPierre ProncheryOSSL_CMP_CTX_set_transfer_cb_arg() or NULL if unset.
410b077aed3SPierre Pronchery
411b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_srvCert() sets the expected server cert in I<ctx> and trusts
412b077aed3SPierre Proncheryit directly (even if it is expired) when verifying signed response messages.
413b077aed3SPierre ProncheryThis pins the accepted CMP server and
414b077aed3SPierre Proncheryresults in ignoring whatever may be set using OSSL_CMP_CTX_set0_trustedStore().
415b077aed3SPierre ProncheryAny previously set value is freed.
416b077aed3SPierre ProncheryThe I<cert> argument may be NULL to clear the entry.
417b077aed3SPierre ProncheryIf set, the subject of the certificate is also used
418b077aed3SPierre Proncheryas default value for the recipient of CMP requests
419b077aed3SPierre Proncheryand as default value for the expected sender of CMP responses.
420b077aed3SPierre Pronchery
421b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_expected_sender() sets the Distinguished Name (DN)
422b077aed3SPierre Proncheryexpected in the sender field of incoming CMP messages.
423b077aed3SPierre ProncheryDefaults to the subject of the pinned server certificate, if any.
424b077aed3SPierre ProncheryThis can be used to make sure that only a particular entity is accepted as
425b077aed3SPierre ProncheryCMP message signer, and attackers are not able to use arbitrary certificates
426b077aed3SPierre Proncheryof a trusted PKI hierarchy to fraudulently pose as CMP server.
427b077aed3SPierre ProncheryNote that this gives slightly more freedom than OSSL_CMP_CTX_set1_srvCert(),
428b077aed3SPierre Proncherywhich pins the server to the holder of a particular certificate, while the
429b077aed3SPierre Proncheryexpected sender name will continue to match after updates of the server cert.
430b077aed3SPierre Pronchery
431b077aed3SPierre ProncheryOSSL_CMP_CTX_set0_trustedStore()
432b077aed3SPierre Proncherysets in the CMP context I<ctx> the certificate store of type X509_STORE
433b077aed3SPierre Proncherycontaining trusted certificates, typically of root CAs.
434b077aed3SPierre ProncheryThis is ignored when a certificate is pinned using OSSL_CMP_CTX_set1_srvCert().
435b077aed3SPierre ProncheryThe store may also hold CRLs and a certificate verification callback function
436b077aed3SPierre Proncheryused for signature-based peer authentication.
437b077aed3SPierre ProncheryAny store entry already set before is freed.
438b077aed3SPierre ProncheryWhen given a NULL parameter the entry is cleared.
439b077aed3SPierre Pronchery
440b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_trustedStore()
441b077aed3SPierre Proncheryextracts from the CMP context I<ctx> the pointer to the currently set
442b077aed3SPierre Proncherycertificate store containing trust anchors etc., or an empty store if unset.
443b077aed3SPierre Pronchery
444b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_untrusted() sets up a list of non-trusted certificates
445b077aed3SPierre Proncheryof intermediate CAs that may be useful for path construction for the own CMP
446b077aed3SPierre Proncherysigner certificate, for the own TLS certificate (if any), when verifying peer
447b077aed3SPierre ProncheryCMP protection certificates, and when verifying newly enrolled certificates.
448b077aed3SPierre ProncheryThe reference counts of those certificates handled successfully are increased.
449b077aed3SPierre Pronchery
450b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_untrusted(OSSL_CMP_CTX *ctx) returns a pointer to the
451b077aed3SPierre Proncherylist of untrusted certs, which may be empty if unset.
452b077aed3SPierre Pronchery
453*6f1af0d7SPierre ProncheryOSSL_CMP_CTX_set1_cert() sets the CMP signer certificate, also called protection
454*6f1af0d7SPierre Proncherycertificate, related to the private key for signature-based message protection.
455b077aed3SPierre ProncheryTherefore the public key of this I<cert> must correspond to
456b077aed3SPierre Proncherythe private key set before or thereafter via OSSL_CMP_CTX_set1_pkey().
457b077aed3SPierre ProncheryWhen using signature-based protection of CMP request messages
458b077aed3SPierre Proncherythis CMP signer certificate will be included first in the extraCerts field.
459b077aed3SPierre ProncheryIt serves as fallback reference certificate, see OSSL_CMP_CTX_set1_oldCert().
460b077aed3SPierre ProncheryThe subject of this I<cert> will be used as the sender field of outgoing
461b077aed3SPierre Proncherymessages, while the subject of any cert set via OSSL_CMP_CTX_set1_oldCert()
462b077aed3SPierre Proncheryand any value set via OSSL_CMP_CTX_set1_subjectName() are used as fallback.
463b077aed3SPierre Pronchery
464b077aed3SPierre ProncheryThe I<cert> argument may be NULL to clear the entry.
465b077aed3SPierre Pronchery
466b077aed3SPierre ProncheryOSSL_CMP_CTX_build_cert_chain() builds a certificate chain for the CMP signer
467b077aed3SPierre Proncherycertificate previously set in the I<ctx>. It adds the optional I<candidates>,
468b077aed3SPierre Proncherya list of intermediate CA certs that may already constitute the targeted chain,
469b077aed3SPierre Proncheryto the untrusted certs that may already exist in the I<ctx>.
470b077aed3SPierre ProncheryThen the function uses this augmented set of certs for chain construction.
471b077aed3SPierre ProncheryIf I<own_trusted> is NULL it builds the chain as far down as possible and
472b077aed3SPierre Proncheryignores any verification errors. Else the CMP signer certificate must be
473b077aed3SPierre Proncheryverifiable where the chain reaches a trust anchor contained in I<own_trusted>.
474b077aed3SPierre ProncheryOn success the function stores the resulting chain in I<ctx>
475b077aed3SPierre Proncheryfor inclusion in the extraCerts field of signature-protected messages.
476b077aed3SPierre ProncheryCalling this function is optional; by default a chain construction
477b077aed3SPierre Proncheryis performed on demand that is equivalent to calling this function
478b077aed3SPierre Proncherywith the I<candidates> and I<own_trusted> arguments being NULL.
479b077aed3SPierre Pronchery
480b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_pkey() sets the client's private key corresponding to the
481b077aed3SPierre ProncheryCMP signer certificate set via OSSL_CMP_CTX_set1_cert().
482b077aed3SPierre ProncheryThis key is used create signature-based protection (protectionAlg = MSG_SIG_ALG)
483b077aed3SPierre Proncheryof outgoing messages
484*6f1af0d7SPierre Proncheryunless a symmetric secret has been set via OSSL_CMP_CTX_set1_secretValue().
485b077aed3SPierre ProncheryThe I<pkey> argument may be NULL to clear the entry.
486b077aed3SPierre Pronchery
487*6f1af0d7SPierre ProncheryOSSL_CMP_CTX_set1_secretValue() sets in I<ctx> the byte string I<sec> of length
488*6f1af0d7SPierre ProncheryI<len> to use as pre-shared secret, or clears it if the I<sec> argument is NULL.
489*6f1af0d7SPierre ProncheryIf present, this secret is used to create MAC-based authentication and integrity
490*6f1af0d7SPierre Proncheryprotection (rather than applying signature-based protection)
491*6f1af0d7SPierre Proncheryof outgoing messages and to verify authenticity and integrity of incoming
492*6f1af0d7SPierre Proncherymessages that have MAC-based protection (protectionAlg = C<MSG_MAC_ALG>).
493b077aed3SPierre Pronchery
494b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_referenceValue() sets the given referenceValue I<ref> with
495b077aed3SPierre Proncherylength I<len> in the given I<ctx> or clears it if the I<ref> argument is NULL.
496b077aed3SPierre ProncheryAccording to RFC 4210 section 5.1.1, if no value for the sender field in
497b077aed3SPierre ProncheryCMP message headers can be determined (i.e., no CMP signer certificate
498b077aed3SPierre Proncheryand no subject DN is set via OSSL_CMP_CTX_set1_subjectName()
499b077aed3SPierre Proncherythen the sender field will contain the NULL-DN
500b077aed3SPierre Proncheryand the senderKID field of the CMP message header must be set.
501b077aed3SPierre ProncheryWhen signature-based protection is used the senderKID will be set to
502b077aed3SPierre Proncherythe subjectKeyIdentifier of the CMP signer certificate as far as present.
503*6f1af0d7SPierre ProncheryIf not present or when MAC-based protection is used
504b077aed3SPierre Proncherythe I<ref> value is taken as the fallback value for the senderKID.
505b077aed3SPierre Pronchery
506b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_recipient() sets the recipient name that will be used in the
507b077aed3SPierre ProncheryPKIHeader of CMP request messages, i.e. the X509 name of the (CA) server.
508b077aed3SPierre Pronchery
509b077aed3SPierre ProncheryThe recipient field in the header of a CMP message is mandatory.
510b077aed3SPierre ProncheryIf not given explicitly the recipient is determined in the following order:
511b077aed3SPierre Proncherythe subject of the CMP server certificate set using OSSL_CMP_CTX_set1_srvCert(),
512b077aed3SPierre Proncherythe value set using OSSL_CMP_CTX_set1_issuer(),
513b077aed3SPierre Proncherythe issuer of the certificate set using OSSL_CMP_CTX_set1_oldCert(),
514b077aed3SPierre Proncherythe issuer of the CMP signer certificate,
515b077aed3SPierre Proncheryas far as any of those is present, else the NULL-DN as last resort.
516b077aed3SPierre Pronchery
517b077aed3SPierre ProncheryOSSL_CMP_CTX_push0_geninfo_ITAV() adds I<itav> to the stack in the I<ctx> to be
518b077aed3SPierre Proncheryadded to the GeneralInfo field of the CMP PKIMessage header of a request
519b077aed3SPierre Proncherymessage sent with this context.
520b077aed3SPierre Pronchery
521b077aed3SPierre ProncheryOSSL_CMP_CTX_reset_geninfo_ITAVs()
522b077aed3SPierre Proncheryclears any ITAVs that were added by OSSL_CMP_CTX_push0_geninfo_ITAV().
523b077aed3SPierre Pronchery
524b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_extraCertsOut() sets the stack of extraCerts that will be
525b077aed3SPierre Proncherysent to remote.
526b077aed3SPierre Pronchery
527b077aed3SPierre ProncheryOSSL_CMP_CTX_set0_newPkey() can be used to explicitly set the given EVP_PKEY
528b077aed3SPierre Proncherystructure as the private or public key to be certified in the CMP context.
529b077aed3SPierre ProncheryThe I<priv> parameter must be 0 if and only if the given key is a public key.
530b077aed3SPierre Pronchery
531b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_newPkey() gives the key to use for certificate enrollment
532b077aed3SPierre Proncherydependent on fields of the CMP context structure:
533b077aed3SPierre Proncherythe newPkey (which may be a private or public key) if present,
534b077aed3SPierre Proncheryelse the public key in the p10CSR if present, else the client's private key.
535b077aed3SPierre ProncheryIf the I<priv> parameter is not 0 and the selected key does not have a
536b077aed3SPierre Proncheryprivate component then NULL is returned.
537b077aed3SPierre Pronchery
538b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_issuer() sets the name of the intended issuer that
539b077aed3SPierre Proncherywill be set in the CertTemplate, i.e., the X509 name of the CA server.
540b077aed3SPierre Pronchery
541b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_subjectName() sets the subject DN that will be used in
542b077aed3SPierre Proncherythe CertTemplate structure when requesting a new cert. For Key Update Requests
543b077aed3SPierre Pronchery(KUR), it defaults to the subject DN of the reference certificate,
544b077aed3SPierre Proncherysee OSSL_CMP_CTX_set1_oldCert(). This default is used for Initialization
545b077aed3SPierre ProncheryRequests (IR) and Certification Requests (CR) only if no SANs are set.
546b077aed3SPierre ProncheryThe I<subjectName> is also used as fallback for the sender field
547b077aed3SPierre Proncheryof outgoing CMP messages if no reference certificate is available.
548b077aed3SPierre Pronchery
549b077aed3SPierre ProncheryOSSL_CMP_CTX_push1_subjectAltName() adds the given X509 name to the list of
550b077aed3SPierre Proncheryalternate names on the certificate template request. This cannot be used if
551b077aed3SPierre Proncheryany Subject Alternative Name extension is set via
552b077aed3SPierre ProncheryOSSL_CMP_CTX_set0_reqExtensions().
553b077aed3SPierre ProncheryBy default, unless B<OSSL_CMP_OPT_SUBJECTALTNAME_NODEFAULT> has been set,
554b077aed3SPierre Proncherythe Subject Alternative Names are copied from the reference certificate,
555b077aed3SPierre Proncherysee OSSL_CMP_CTX_set1_oldCert().
556b077aed3SPierre ProncheryIf set and the subject DN is not set with OSSL_CMP_CTX_set1_subjectName() then
557b077aed3SPierre Proncherythe certificate template of an IR and CR will not be filled with the default
558b077aed3SPierre Proncherysubject DN from the reference certificate.
559b077aed3SPierre ProncheryIf a subject DN is desired it needs to be set explicitly with
560b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_subjectName().
561b077aed3SPierre Pronchery
562b077aed3SPierre ProncheryOSSL_CMP_CTX_set0_reqExtensions() sets the X.509v3 extensions to be used in
563b077aed3SPierre ProncheryIR/CR/KUR.
564b077aed3SPierre Pronchery
565b077aed3SPierre ProncheryOSSL_CMP_CTX_reqExtensions_have_SAN() returns 1 if the context contains
566b077aed3SPierre Proncherya Subject Alternative Name extension, else 0 or -1 on error.
567b077aed3SPierre Pronchery
568b077aed3SPierre ProncheryOSSL_CMP_CTX_push0_policy() adds the certificate policy info object
569b077aed3SPierre Proncheryto the X509_EXTENSIONS of the requested certificate template.
570b077aed3SPierre Pronchery
571b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_oldCert() sets the old certificate to be updated in
572b077aed3SPierre ProncheryKey Update Requests (KUR) or to be revoked in Revocation Requests (RR).
573b077aed3SPierre ProncheryIt must be given for RR, else it defaults to the CMP signer certificate.
574b077aed3SPierre ProncheryThe I<reference certificate> determined in this way, if any, is also used for
575b077aed3SPierre Proncheryderiving default subject DN, public key, Subject Alternative Names, and the
576b077aed3SPierre Proncherydefault issuer entry in the requested certificate template of IR/CR/KUR.
577b077aed3SPierre ProncheryThe subject of the reference certificate is used as the sender field value
578b077aed3SPierre Proncheryin CMP message headers.
579b077aed3SPierre ProncheryIts issuer is used as default recipient in CMP message headers.
580b077aed3SPierre Pronchery
581b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_p10CSR() sets the PKCS#10 CSR to use in P10CR messages.
582b077aed3SPierre ProncheryIf such a CSR is provided, its subject, public key, and extension fields are
583b077aed3SPierre Proncheryalso used as fallback values for the certificate template of IR/CR/KUR messages.
584b077aed3SPierre Pronchery
585b077aed3SPierre ProncheryOSSL_CMP_CTX_push0_genm_ITAV() adds I<itav> to the stack in the I<ctx> which
586b077aed3SPierre Proncherywill be the body of a General Message sent with this context.
587b077aed3SPierre Pronchery
588b077aed3SPierre ProncheryOSSL_CMP_certConf_cb() is the default certificate confirmation callback function.
589b077aed3SPierre ProncheryIf the callback argument is not NULL it must point to a trust store.
590b077aed3SPierre ProncheryIn this case the function checks that the newly enrolled certificate can be
591b077aed3SPierre Proncheryverified using this trust store and untrusted certificates from the I<ctx>,
592b077aed3SPierre Proncherywhich have been augmented by the list of extraCerts received.
593b077aed3SPierre ProncheryDuring this verification, any certificate status checking is disabled.
594b077aed3SPierre ProncheryIf the callback argument is NULL the function tries building an approximate
595b077aed3SPierre Proncherychain as far as possible using the same untrusted certificates from the I<ctx>,
596b077aed3SPierre Proncheryand if this fails it takes the received extraCerts as fallback.
597b077aed3SPierre ProncheryThe resulting cert chain can be retrieved using OSSL_CMP_CTX_get1_newChain().
598b077aed3SPierre Pronchery
599b077aed3SPierre ProncheryOSSL_CMP_CTX_set_certConf_cb() sets the callback used for evaluating the newly
600b077aed3SPierre Proncheryenrolled certificate before the library sends, depending on its result,
601b077aed3SPierre Proncherya positive or negative certConf message to the server. The callback has type
602b077aed3SPierre Pronchery
603b077aed3SPierre Pronchery typedef int (*OSSL_CMP_certConf_cb_t) (OSSL_CMP_CTX *ctx, X509 *cert,
604b077aed3SPierre Pronchery                                        int fail_info, const char **txt);
605b077aed3SPierre Pronchery
606b077aed3SPierre Proncheryand should inspect the certificate it obtains via the I<cert> parameter and may
607b077aed3SPierre Proncheryoverrule the pre-decision given in the I<fail_info> and I<*txt> parameters.
608b077aed3SPierre ProncheryIf it accepts the certificate it must return 0, indicating success. Else it must
609b077aed3SPierre Proncheryreturn a bit field reflecting PKIFailureInfo with at least one failure bit and
610b077aed3SPierre Proncherymay set the I<*txt> output parameter to point to a string constant with more
611b077aed3SPierre Proncherydetail.  The transfer callback may make use of a custom defined argument stored
612b077aed3SPierre Proncheryin the I<ctx> by means of OSSL_CMP_CTX_set_certConf_cb_arg(), which may be
613b077aed3SPierre Proncheryretrieved again through OSSL_CMP_CTX_get_certConf_cb_arg().
614b077aed3SPierre ProncheryTypically, the callback will check at least that the certificate can be verified
615b077aed3SPierre Proncheryusing a set of trusted certificates.
616b077aed3SPierre ProncheryIt also could compare the subject DN and other fields of the newly
617b077aed3SPierre Proncheryenrolled certificate with the certificate template of the request.
618b077aed3SPierre Pronchery
619b077aed3SPierre ProncheryOSSL_CMP_CTX_set_certConf_cb_arg() sets an argument, respectively a pointer to a
620b077aed3SPierre Proncherystructure containing arguments, optionally to be used by the certConf callback.
621b077aed3SPierre ProncheryI<arg> is not consumed, and it must therefore explicitly be freed when not
622b077aed3SPierre Proncheryneeded any more. I<arg> may be NULL to clear the entry.
623b077aed3SPierre Pronchery
624b077aed3SPierre ProncheryOSSL_CMP_CTX_get_certConf_cb_arg() gets the argument, respectively the pointer
625b077aed3SPierre Proncheryto a structure containing arguments, previously set by
626b077aed3SPierre ProncheryOSSL_CMP_CTX_set_certConf_cb_arg(), or NULL if unset.
627b077aed3SPierre Pronchery
628b077aed3SPierre ProncheryOSSL_CMP_CTX_get_status() returns for client contexts the PKIstatus from
629b077aed3SPierre Proncherythe last received CertRepMessage or Revocation Response or error message:
630aa795734SPierre Pronchery=item B<OSSL_CMP_PKISTATUS_accepted> on successful receipt of a GENP message:
631b077aed3SPierre Pronchery
632b077aed3SPierre Pronchery=over 4
633b077aed3SPierre Pronchery
634b077aed3SPierre Pronchery=item B<OSSL_CMP_PKISTATUS_request>
635b077aed3SPierre Pronchery
636b077aed3SPierre Proncheryif an IR/CR/KUR/RR/GENM request message could not be produced,
637b077aed3SPierre Pronchery
638b077aed3SPierre Pronchery=item B<OSSL_CMP_PKISTATUS_trans>
639b077aed3SPierre Pronchery
640b077aed3SPierre Proncheryon a transmission error or transaction error for this type of request, and
641b077aed3SPierre Pronchery
642b077aed3SPierre Pronchery=item B<OSSL_CMP_PKISTATUS_unspecified>
643b077aed3SPierre Pronchery
644b077aed3SPierre Proncheryif no such request was attempted or OSSL_CMP_CTX_reinit() has been called.
645b077aed3SPierre Pronchery
646b077aed3SPierre Pronchery=back
647b077aed3SPierre Pronchery
648b077aed3SPierre ProncheryFor server contexts it returns
649b077aed3SPierre ProncheryB<OSSL_CMP_PKISTATUS_trans> if a transaction is open,
650b077aed3SPierre Proncheryotherwise B<OSSL_CMP_PKISTATUS_unspecified>.
651b077aed3SPierre Pronchery
652b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_statusString() returns the statusString from the last received
653b077aed3SPierre ProncheryCertRepMessage or Revocation Response or error message, or NULL if unset.
654b077aed3SPierre Pronchery
655b077aed3SPierre ProncheryOSSL_CMP_CTX_get_failInfoCode() returns the error code from the failInfo field
656b077aed3SPierre Proncheryof the last received CertRepMessage or Revocation Response or error message,
657b077aed3SPierre Proncheryor -1 if no such response was received or OSSL_CMP_CTX_reinit() has been called.
658b077aed3SPierre ProncheryThis is a bit field and the flags for it are specified in the header file
659b077aed3SPierre ProncheryF<< <openssl/cmp.h> >>.
660b077aed3SPierre ProncheryThe flags start with OSSL_CMP_CTX_FAILINFO, for example:
661b077aed3SPierre ProncheryOSSL_CMP_CTX_FAILINFO_badAlg. Returns -1 if the failInfoCode field is unset.
662b077aed3SPierre Pronchery
663b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_newCert() returns the pointer to the newly obtained
664b077aed3SPierre Proncherycertificate in case it is available, else NULL.
665b077aed3SPierre Pronchery
666b077aed3SPierre ProncheryOSSL_CMP_CTX_get1_newChain() returns a pointer to a duplicate of the stack of
667b077aed3SPierre ProncheryX.509 certificates computed by OSSL_CMP_certConf_cb() (if this function has
668b077aed3SPierre Proncherybeen called) on the last received certificate response message IP/CP/KUP.
669b077aed3SPierre Pronchery
670b077aed3SPierre ProncheryOSSL_CMP_CTX_get1_caPubs() returns a pointer to a duplicate of the list of
671b077aed3SPierre ProncheryX.509 certificates in the caPubs field of the last received certificate
672b077aed3SPierre Proncheryresponse message (of type IP, CP, or KUP),
673b077aed3SPierre Proncheryor an empty stack if no caPubs have been received in the current transaction.
674b077aed3SPierre Pronchery
675b077aed3SPierre ProncheryOSSL_CMP_CTX_get1_extraCertsIn() returns a pointer to a duplicate of the list
676b077aed3SPierre Proncheryof X.509 certificates contained in the extraCerts field of the last received
677b077aed3SPierre Proncheryresponse message (except for pollRep and PKIConf), or
678b077aed3SPierre Proncheryan empty stack if no extraCerts have been received in the current transaction.
679b077aed3SPierre Pronchery
680b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_transactionID() sets the given transaction ID in the given
681b077aed3SPierre ProncheryOSSL_CMP_CTX structure.
682b077aed3SPierre Pronchery
683b077aed3SPierre ProncheryOSSL_CMP_CTX_set1_senderNonce() stores the last sent sender I<nonce> in
684b077aed3SPierre Proncherythe I<ctx>. This will be used to validate the recipNonce in incoming messages.
685b077aed3SPierre Pronchery
686b077aed3SPierre Pronchery=head1 NOTES
687b077aed3SPierre Pronchery
688b077aed3SPierre ProncheryCMP is defined in RFC 4210 (and CRMF in RFC 4211).
689b077aed3SPierre Pronchery
690b077aed3SPierre Pronchery=head1 RETURN VALUES
691b077aed3SPierre Pronchery
692b077aed3SPierre ProncheryOSSL_CMP_CTX_free() and OSSL_CMP_CTX_print_errors() do not return anything.
693b077aed3SPierre Pronchery
694b077aed3SPierre ProncheryOSSL_CMP_CTX_new(),
695b077aed3SPierre ProncheryOSSL_CMP_CTX_get_http_cb_arg(),
696b077aed3SPierre ProncheryOSSL_CMP_CTX_get_transfer_cb_arg(),
697b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_trustedStore(),
698b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_untrusted(),
699b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_newPkey(),
700b077aed3SPierre ProncheryOSSL_CMP_CTX_get_certConf_cb_arg(),
701b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_statusString(),
702b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_newCert(),
703b077aed3SPierre ProncheryOSSL_CMP_CTX_get0_newChain(),
704b077aed3SPierre ProncheryOSSL_CMP_CTX_get1_caPubs(), and
705b077aed3SPierre ProncheryOSSL_CMP_CTX_get1_extraCertsIn()
706b077aed3SPierre Proncheryreturn the intended pointer value as described above or NULL on error.
707b077aed3SPierre Pronchery
708b077aed3SPierre ProncheryOSSL_CMP_CTX_get_option(),
709b077aed3SPierre ProncheryOSSL_CMP_CTX_reqExtensions_have_SAN(),
710b077aed3SPierre ProncheryOSSL_CMP_CTX_get_status(), and
711b077aed3SPierre ProncheryOSSL_CMP_CTX_get_failInfoCode()
712b077aed3SPierre Proncheryreturn the intended value as described above or -1 on error.
713b077aed3SPierre Pronchery
714b077aed3SPierre ProncheryOSSL_CMP_certConf_cb() returns I<fail_info> if it is not equal to 0,
715b077aed3SPierre Proncheryelse 0 on successful validation,
716b077aed3SPierre Proncheryor else a bit field with the B<OSSL_CMP_PKIFAILUREINFO_incorrectData> bit set.
717b077aed3SPierre Pronchery
718b077aed3SPierre ProncheryAll other functions, including OSSL_CMP_CTX_reinit()
719b077aed3SPierre Proncheryand OSSL_CMP_CTX_reset_geninfo_ITAVs(),
720b077aed3SPierre Proncheryreturn 1 on success, 0 on error.
721b077aed3SPierre Pronchery
722b077aed3SPierre Pronchery=head1 EXAMPLES
723b077aed3SPierre Pronchery
724b077aed3SPierre ProncheryThe following code omits error handling.
725b077aed3SPierre Pronchery
726b077aed3SPierre ProncherySet up a CMP client context for sending requests and verifying responses:
727b077aed3SPierre Pronchery
728b077aed3SPierre Pronchery    cmp_ctx = OSSL_CMP_CTX_new();
729b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_server(cmp_ctx, name_or_address);
730b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_serverPort(cmp_ctx, port_string);
731b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_serverPath(cmp_ctx, path_or_alias);
732b077aed3SPierre Pronchery    OSSL_CMP_CTX_set0_trustedStore(cmp_ctx, ts);
733b077aed3SPierre Pronchery
734*6f1af0d7SPierre ProncherySet up symmetric credentials for MAC-based message protection such as PBM:
735b077aed3SPierre Pronchery
736b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_referenceValue(cmp_ctx, ref, ref_len);
737b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_secretValue(cmp_ctx, sec, sec_len);
738b077aed3SPierre Pronchery
739b077aed3SPierre ProncherySet up the details for certificate requests:
740b077aed3SPierre Pronchery
741b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_subjectName(cmp_ctx, name);
742b077aed3SPierre Pronchery    OSSL_CMP_CTX_set0_newPkey(cmp_ctx, 1, initialKey);
743b077aed3SPierre Pronchery
744b077aed3SPierre ProncheryPerform an Initialization Request transaction:
745b077aed3SPierre Pronchery
746b077aed3SPierre Pronchery    initialCert = OSSL_CMP_exec_IR_ses(cmp_ctx);
747b077aed3SPierre Pronchery
748b077aed3SPierre ProncheryReset the transaction state of the CMP context and the credentials:
749b077aed3SPierre Pronchery
750b077aed3SPierre Pronchery    OSSL_CMP_CTX_reinit(cmp_ctx);
751b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_referenceValue(cmp_ctx, NULL, 0);
752b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_secretValue(cmp_ctx, NULL, 0);
753b077aed3SPierre Pronchery
754b077aed3SPierre ProncheryPerform a Certification Request transaction, making use of the new credentials:
755b077aed3SPierre Pronchery
756b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_cert(cmp_ctx, initialCert);
757b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_pkey(cmp_ctx, initialKey);
758b077aed3SPierre Pronchery    OSSL_CMP_CTX_set0_newPkey(cmp_ctx, 1, curentKey);
759b077aed3SPierre Pronchery    currentCert = OSSL_CMP_exec_CR_ses(cmp_ctx);
760b077aed3SPierre Pronchery
761b077aed3SPierre ProncheryPerform a Key Update Request, signed using the cert (and key) to be updated:
762b077aed3SPierre Pronchery
763b077aed3SPierre Pronchery    OSSL_CMP_CTX_reinit(cmp_ctx);
764b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_cert(cmp_ctx, currentCert);
765b077aed3SPierre Pronchery    OSSL_CMP_CTX_set1_pkey(cmp_ctx, currentKey);
766b077aed3SPierre Pronchery    OSSL_CMP_CTX_set0_newPkey(cmp_ctx, 1, updatedKey);
767b077aed3SPierre Pronchery    currentCert = OSSL_CMP_exec_KUR_ses(cmp_ctx);
768b077aed3SPierre Pronchery    currentKey = updatedKey;
769b077aed3SPierre Pronchery
770b077aed3SPierre ProncheryPerform a General Message transaction including, as an example,
771b077aed3SPierre Proncherythe id-it-signKeyPairTypes OID and prints info on the General Response contents:
772b077aed3SPierre Pronchery
773b077aed3SPierre Pronchery    OSSL_CMP_CTX_reinit(cmp_ctx);
774b077aed3SPierre Pronchery
775b077aed3SPierre Pronchery    ASN1_OBJECT *type = OBJ_txt2obj("1.3.6.1.5.5.7.4.2", 1);
776b077aed3SPierre Pronchery    OSSL_CMP_ITAV *itav = OSSL_CMP_ITAV_create(type, NULL);
777b077aed3SPierre Pronchery    OSSL_CMP_CTX_push0_genm_ITAV(cmp_ctx, itav);
778b077aed3SPierre Pronchery
779b077aed3SPierre Pronchery    STACK_OF(OSSL_CMP_ITAV) *itavs;
780b077aed3SPierre Pronchery    itavs = OSSL_CMP_exec_GENM_ses(cmp_ctx);
781b077aed3SPierre Pronchery    print_itavs(itavs);
782b077aed3SPierre Pronchery    sk_OSSL_CMP_ITAV_pop_free(itavs, OSSL_CMP_ITAV_free);
783b077aed3SPierre Pronchery
784b077aed3SPierre Pronchery=head1 SEE ALSO
785b077aed3SPierre Pronchery
786b077aed3SPierre ProncheryL<OSSL_CMP_exec_IR_ses(3)>, L<OSSL_CMP_exec_CR_ses(3)>,
787b077aed3SPierre ProncheryL<OSSL_CMP_exec_KUR_ses(3)>, L<OSSL_CMP_exec_GENM_ses(3)>,
788b077aed3SPierre ProncheryL<OSSL_CMP_exec_certreq(3)>, L<OSSL_CMP_MSG_http_perform(3)>,
789b077aed3SPierre ProncheryL<ERR_print_errors_cb(3)>
790b077aed3SPierre Pronchery
791b077aed3SPierre Pronchery=head1 HISTORY
792b077aed3SPierre Pronchery
793b077aed3SPierre ProncheryThe OpenSSL CMP support was added in OpenSSL 3.0.
794b077aed3SPierre Pronchery
795b077aed3SPierre ProncheryOSSL_CMP_CTX_reset_geninfo_ITAVs() was added in OpenSSL 3.0.8.
796b077aed3SPierre Pronchery
797b077aed3SPierre Pronchery=head1 COPYRIGHT
798b077aed3SPierre Pronchery
799b077aed3SPierre ProncheryCopyright 2007-2023 The OpenSSL Project Authors. All Rights Reserved.
800b077aed3SPierre Pronchery
801b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
802b077aed3SPierre Proncherythis file except in compliance with the License.  You can obtain a copy
803b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at
804b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>.
805b077aed3SPierre Pronchery
806b077aed3SPierre Pronchery=cut
807