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