]> git.ipfire.org Git - thirdparty/openssl.git/blame - doc/man3/OSSL_CMP_SRV_CTX_new.pod
crypto/cmp/,apps/lib/cmp_mock_srv.c: various improvements on delayed delivery
[thirdparty/openssl.git] / doc / man3 / OSSL_CMP_SRV_CTX_new.pod
CommitLineData
62dcd2aa
DDO
1=pod
2
3=head1 NAME
4
5OSSL_CMP_SRV_process_request,
6OSSL_CMP_CTX_server_perform,
7OSSL_CMP_SRV_CTX_new,
8OSSL_CMP_SRV_CTX_free,
9OSSL_CMP_SRV_cert_request_cb_t,
10OSSL_CMP_SRV_rr_cb_t,
11OSSL_CMP_SRV_certConf_cb_t,
12OSSL_CMP_SRV_genm_cb_t,
13OSSL_CMP_SRV_error_cb_t,
14OSSL_CMP_SRV_pollReq_cb_t,
15OSSL_CMP_SRV_CTX_init,
bedffe17
DDO
16OSSL_CMP_SRV_delayed_delivery_cb_t,
17OSSL_CMP_SRV_clean_transaction_cb_t,
18OSSL_CMP_SRV_CTX_init_trans,
62dcd2aa
DDO
19OSSL_CMP_SRV_CTX_get0_cmp_ctx,
20OSSL_CMP_SRV_CTX_get0_custom_ctx,
21OSSL_CMP_SRV_CTX_set_send_unprotected_errors,
22OSSL_CMP_SRV_CTX_set_accept_unprotected,
23OSSL_CMP_SRV_CTX_set_accept_raverified,
24OSSL_CMP_SRV_CTX_set_grant_implicit_confirm
25- generic functions to set up and control a CMP server
26
27=head1 SYNOPSIS
28
29 #include <openssl/cmp.h>
30
31 OSSL_CMP_MSG *OSSL_CMP_SRV_process_request(OSSL_CMP_SRV_CTX *srv_ctx,
32 const OSSL_CMP_MSG *req);
33 OSSL_CMP_MSG *OSSL_CMP_CTX_server_perform(OSSL_CMP_CTX *client_ctx,
34 const OSSL_CMP_MSG *req);
b4250010 35 OSSL_CMP_SRV_CTX *OSSL_CMP_SRV_CTX_new(OSSL_LIB_CTX *libctx, const char *propq);
62dcd2aa
DDO
36 void OSSL_CMP_SRV_CTX_free(OSSL_CMP_SRV_CTX *srv_ctx);
37
38 typedef OSSL_CMP_PKISI *(*OSSL_CMP_SRV_cert_request_cb_t)(
39 OSSL_CMP_SRV_CTX *srv_ctx,
40 const OSSL_CMP_MSG *req,
41 int certReqId,
42 const OSSL_CRMF_MSG *crm,
43 const X509_REQ *p10cr,
44 X509 **certOut,
45 STACK_OF(X509) **chainOut,
46 STACK_OF(X509) **caPubs);
47 typedef OSSL_CMP_PKISI *(*OSSL_CMP_SRV_rr_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
48 const OSSL_CMP_MSG *req,
49 const X509_NAME *issuer,
50 const ASN1_INTEGER *serial);
51 typedef int (*OSSL_CMP_SRV_genm_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
52 const OSSL_CMP_MSG *req,
53 STACK_OF(OSSL_CMP_ITAV) *in,
54 STACK_OF(OSSL_CMP_ITAV) **out);
55 typedef void (*OSSL_CMP_SRV_error_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
56 const OSSL_CMP_MSG *req,
57 const OSSL_CMP_PKISI *statusInfo,
58 const ASN1_INTEGER *errorCode,
59 const OSSL_CMP_PKIFREETEXT *errorDetails);
60 typedef int (*OSSL_CMP_SRV_certConf_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
61 const OSSL_CMP_MSG *req,
62 int certReqId,
63 const ASN1_OCTET_STRING *certHash,
64 const OSSL_CMP_PKISI *si);
65 typedef int (*OSSL_CMP_SRV_pollReq_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
66 const OSSL_CMP_MSG *req,
67 int certReqId,
68 OSSL_CMP_MSG **certReq,
69 int64_t *check_after);
70 int OSSL_CMP_SRV_CTX_init(OSSL_CMP_SRV_CTX *srv_ctx, void *custom_ctx,
71 OSSL_CMP_SRV_cert_request_cb_t process_cert_request,
72 OSSL_CMP_SRV_rr_cb_t process_rr,
73 OSSL_CMP_SRV_genm_cb_t process_genm,
74 OSSL_CMP_SRV_error_cb_t process_error,
75 OSSL_CMP_SRV_certConf_cb_t process_certConf,
76 OSSL_CMP_SRV_pollReq_cb_t process_pollReq);
bedffe17
DDO
77 typedef int (*OSSL_CMP_SRV_delayed_delivery_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
78 const OSSL_CMP_MSG *req);
79 typedef int (*OSSL_CMP_SRV_clean_transaction_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
80 const ASN1_OCTET_STRING *id);
81 int OSSL_CMP_SRV_CTX_init_trans(OSSL_CMP_SRV_CTX *srv_ctx,
82 OSSL_CMP_SRV_delayed_delivery_cb_t delay,
83 OSSL_CMP_SRV_clean_transaction_cb_t clean);
62dcd2aa
DDO
84
85 OSSL_CMP_CTX *OSSL_CMP_SRV_CTX_get0_cmp_ctx(const OSSL_CMP_SRV_CTX *srv_ctx);
86 void *OSSL_CMP_SRV_CTX_get0_custom_ctx(const OSSL_CMP_SRV_CTX *srv_ctx);
87
88 int OSSL_CMP_SRV_CTX_set_send_unprotected_errors(OSSL_CMP_SRV_CTX *srv_ctx,
89 int val);
90 int OSSL_CMP_SRV_CTX_set_accept_unprotected(OSSL_CMP_SRV_CTX *srv_ctx, int val);
91 int OSSL_CMP_SRV_CTX_set_accept_raverified(OSSL_CMP_SRV_CTX *srv_ctx, int val);
92 int OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(OSSL_CMP_SRV_CTX *srv_ctx,
93 int val);
94
95=head1 DESCRIPTION
96
97OSSL_CMP_SRV_process_request() implements the generic aspects of a CMP server.
5a2ba207
DDO
98Its arguments are the B<OSSL_CMP_SRV_CTX> I<srv_ctx> and the CMP request message
99I<req>. It does the typical generic checks on I<req>, calls
62dcd2aa
DDO
100the respective callback function (if present) for more specific processing,
101and then assembles a result message, which may be a CMP error message.
19f97fe6
DDO
102If after return of the function the expression
103I<OSSL_CMP_CTX_get_status(OSSL_CMP_SRV_CTX_get0_cmp_ctx(srv_ctx))> yields -1
104then the function has closed the current transaction,
105which may be due to normal successful end of the transaction or due to an error.
62dcd2aa
DDO
106
107OSSL_CMP_CTX_server_perform() is an interface to
f5f4fbaa
RL
108OSSL_CMP_SRV_process_request() that can be used by a CMP client
109in the same way as L<OSSL_CMP_MSG_http_perform(3)>.
5a2ba207 110The B<OSSL_CMP_SRV_CTX> must be set as I<transfer_cb_arg> of I<client_ctx>.
62dcd2aa 111
1a7cd250 112OSSL_CMP_SRV_CTX_new() creates and initializes an B<OSSL_CMP_SRV_CTX> structure
57cd10dd 113associated with the library context I<libctx> and property query string
1a7cd250 114I<propq>, both of which may be NULL to select the defaults.
62dcd2aa 115
5a2ba207 116OSSL_CMP_SRV_CTX_free() deletes the given I<srv_ctx>.
62dcd2aa 117
5a2ba207 118OSSL_CMP_SRV_CTX_init() sets in the given I<srv_ctx> a custom server context
62dcd2aa
DDO
119pointer as well as callback functions performing the specific processing of CMP
120certificate requests, revocation requests, certificate confirmation requests,
121general messages, error messages, and poll requests.
5a2ba207 122All arguments except I<srv_ctx> may be NULL.
62dcd2aa
DDO
123If a callback for some message type is not given this means that the respective
124type of CMP message is not supported by the server.
125
bedffe17
DDO
126OSSL_CMP_SRV_CTX_init_trans() sets in I<srv_ctx> the optional callback
127functions for initiating delayed delivery and cleaning up a transaction.
128If the <delay> function is NULL then delivery of responses is never delayed.
129Otherwise I<delay> takes a custom server context and a request message as input.
130It must return 1 if delivery of the respecive response shall be delayed,
1310 if not, and -1 on error.
132If the <clean> function is NULL then no specific cleanup is performed.
133Otherwise I<clean> takes a custom server context and a transaction ID pointer
134as input, where the pointer is NULL in case a new transaction is being started
135and otherwise provides the ID of the transaction being terminated.
136The <clean> function should reset the respective portions of the state
137and free related memory.
138It must return 1 on success and 0 on error.
192bfec4 139
5a2ba207 140OSSL_CMP_SRV_CTX_get0_cmp_ctx() returns the B<OSSL_CMP_CTX> from the I<srv_ctx>.
62dcd2aa
DDO
141
142OSSL_CMP_SRV_CTX_get0_custom_ctx() returns the custom server context from
f5f4fbaa 143I<srv_ctx> that has been set using OSSL_CMP_SRV_CTX_init().
62dcd2aa
DDO
144
145OSSL_CMP_SRV_CTX_set_send_unprotected_errors() enables sending error messages
146and other forms of negative responses unprotected.
147
148OSSL_CMP_SRV_CTX_set_accept_unprotected() enables acceptance of requests
149without protection of with invalid protection.
150
151OSSL_CMP_SRV_CTX_set_accept_raverified() enables acceptance of ir/cr/kur
152messages with POPO 'RAVerified'.
153
154OSSL_CMP_SRV_CTX_set_grant_implicit_confirm() enables granting implicit
155confirmation of newly enrolled certificates if requested.
156
157=head1 NOTES
158
159CMP is defined in RFC 4210 (and CRMF in RFC 4211).
160
7e765f46
DDO
161So far the CMP server implementation is limited to one request per CMP message
162(and consequently to at most one response component per CMP message).
163
62dcd2aa
DDO
164=head1 RETURN VALUES
165
166OSSL_CMP_SRV_CTX_new() returns a B<OSSL_CMP_SRV_CTX> structure on success,
167NULL on error.
168
169OSSL_CMP_SRV_CTX_free() does not return a value.
170
171OSSL_CMP_SRV_CTX_get0_cmp_ctx() returns a B<OSSL_CMP_CTX> structure on success,
172NULL on error.
173
174OSSL_CMP_SRV_CTX_get0_custom_ctx() returns the custom server context
f5f4fbaa 175that has been set using OSSL_CMP_SRV_CTX_init().
62dcd2aa
DDO
176
177All other functions return 1 on success, 0 on error.
178
179=head1 HISTORY
180
181The OpenSSL CMP support was added in OpenSSL 3.0.
182
bedffe17
DDO
183OSSL_CMP_SRV_CTX_init_trans()
184supporting delayed delivery of all types of response messages
185was added in OpenSSL 3.3.
186
62dcd2aa
DDO
187=head1 COPYRIGHT
188
4333b89f 189Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
62dcd2aa
DDO
190
191Licensed under the Apache License 2.0 (the "License"). You may not use
192this file except in compliance with the License. You can obtain a copy
193in the file LICENSE in the source distribution or at
194L<https://www.openssl.org/source/license.html>.
195
196=cut