OSSL_CMP_SRV_CTX_new.pod 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. =pod
  2. =head1 NAME
  3. OSSL_CMP_SRV_process_request,
  4. OSSL_CMP_CTX_server_perform,
  5. OSSL_CMP_SRV_CTX_new,
  6. OSSL_CMP_SRV_CTX_free,
  7. OSSL_CMP_SRV_cert_request_cb_t,
  8. OSSL_CMP_SRV_rr_cb_t,
  9. OSSL_CMP_SRV_certConf_cb_t,
  10. OSSL_CMP_SRV_genm_cb_t,
  11. OSSL_CMP_SRV_error_cb_t,
  12. OSSL_CMP_SRV_pollReq_cb_t,
  13. OSSL_CMP_SRV_CTX_init,
  14. OSSL_CMP_SRV_CTX_get0_cmp_ctx,
  15. OSSL_CMP_SRV_CTX_get0_custom_ctx,
  16. OSSL_CMP_SRV_CTX_set_send_unprotected_errors,
  17. OSSL_CMP_SRV_CTX_set_accept_unprotected,
  18. OSSL_CMP_SRV_CTX_set_accept_raverified,
  19. OSSL_CMP_SRV_CTX_set_grant_implicit_confirm
  20. - generic functions to set up and control a CMP server
  21. =head1 SYNOPSIS
  22. #include <openssl/cmp.h>
  23. OSSL_CMP_MSG *OSSL_CMP_SRV_process_request(OSSL_CMP_SRV_CTX *srv_ctx,
  24. const OSSL_CMP_MSG *req);
  25. OSSL_CMP_MSG *OSSL_CMP_CTX_server_perform(OSSL_CMP_CTX *client_ctx,
  26. const OSSL_CMP_MSG *req);
  27. OSSL_CMP_SRV_CTX *OSSL_CMP_SRV_CTX_new(OSSL_LIB_CTX *libctx, const char *propq);
  28. void OSSL_CMP_SRV_CTX_free(OSSL_CMP_SRV_CTX *srv_ctx);
  29. typedef OSSL_CMP_PKISI *(*OSSL_CMP_SRV_cert_request_cb_t)(
  30. OSSL_CMP_SRV_CTX *srv_ctx,
  31. const OSSL_CMP_MSG *req,
  32. int certReqId,
  33. const OSSL_CRMF_MSG *crm,
  34. const X509_REQ *p10cr,
  35. X509 **certOut,
  36. STACK_OF(X509) **chainOut,
  37. STACK_OF(X509) **caPubs);
  38. typedef OSSL_CMP_PKISI *(*OSSL_CMP_SRV_rr_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
  39. const OSSL_CMP_MSG *req,
  40. const X509_NAME *issuer,
  41. const ASN1_INTEGER *serial);
  42. typedef int (*OSSL_CMP_SRV_genm_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
  43. const OSSL_CMP_MSG *req,
  44. STACK_OF(OSSL_CMP_ITAV) *in,
  45. STACK_OF(OSSL_CMP_ITAV) **out);
  46. typedef void (*OSSL_CMP_SRV_error_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
  47. const OSSL_CMP_MSG *req,
  48. const OSSL_CMP_PKISI *statusInfo,
  49. const ASN1_INTEGER *errorCode,
  50. const OSSL_CMP_PKIFREETEXT *errorDetails);
  51. typedef int (*OSSL_CMP_SRV_certConf_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
  52. const OSSL_CMP_MSG *req,
  53. int certReqId,
  54. const ASN1_OCTET_STRING *certHash,
  55. const OSSL_CMP_PKISI *si);
  56. typedef int (*OSSL_CMP_SRV_pollReq_cb_t)(OSSL_CMP_SRV_CTX *srv_ctx,
  57. const OSSL_CMP_MSG *req,
  58. int certReqId,
  59. OSSL_CMP_MSG **certReq,
  60. int64_t *check_after);
  61. int OSSL_CMP_SRV_CTX_init(OSSL_CMP_SRV_CTX *srv_ctx, void *custom_ctx,
  62. OSSL_CMP_SRV_cert_request_cb_t process_cert_request,
  63. OSSL_CMP_SRV_rr_cb_t process_rr,
  64. OSSL_CMP_SRV_genm_cb_t process_genm,
  65. OSSL_CMP_SRV_error_cb_t process_error,
  66. OSSL_CMP_SRV_certConf_cb_t process_certConf,
  67. OSSL_CMP_SRV_pollReq_cb_t process_pollReq);
  68. OSSL_CMP_CTX *OSSL_CMP_SRV_CTX_get0_cmp_ctx(const OSSL_CMP_SRV_CTX *srv_ctx);
  69. void *OSSL_CMP_SRV_CTX_get0_custom_ctx(const OSSL_CMP_SRV_CTX *srv_ctx);
  70. int OSSL_CMP_SRV_CTX_set_send_unprotected_errors(OSSL_CMP_SRV_CTX *srv_ctx,
  71. int val);
  72. int OSSL_CMP_SRV_CTX_set_accept_unprotected(OSSL_CMP_SRV_CTX *srv_ctx, int val);
  73. int OSSL_CMP_SRV_CTX_set_accept_raverified(OSSL_CMP_SRV_CTX *srv_ctx, int val);
  74. int OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(OSSL_CMP_SRV_CTX *srv_ctx,
  75. int val);
  76. =head1 DESCRIPTION
  77. OSSL_CMP_SRV_process_request() implements the generic aspects of a CMP server.
  78. Its arguments are the B<OSSL_CMP_SRV_CTX> I<srv_ctx> and the CMP request message
  79. I<req>. It does the typical generic checks on I<req>, calls
  80. the respective callback function (if present) for more specific processing,
  81. and then assembles a result message, which may be a CMP error message.
  82. If after return of the function the expression
  83. I<OSSL_CMP_CTX_get_status(OSSL_CMP_SRV_CTX_get0_cmp_ctx(srv_ctx))> yields -1
  84. then the function has closed the current transaction,
  85. which may be due to normal successful end of the transaction or due to an error.
  86. OSSL_CMP_CTX_server_perform() is an interface to
  87. OSSL_CMP_SRV_process_request() that can be used by a CMP client
  88. in the same way as L<OSSL_CMP_MSG_http_perform(3)>.
  89. The B<OSSL_CMP_SRV_CTX> must be set as I<transfer_cb_arg> of I<client_ctx>.
  90. OSSL_CMP_SRV_CTX_new() creates and initializes an B<OSSL_CMP_SRV_CTX> structure
  91. associated with the library context I<libctx> and property query string
  92. I<propq>, both of which may be NULL to select the defaults.
  93. OSSL_CMP_SRV_CTX_free() deletes the given I<srv_ctx>.
  94. OSSL_CMP_SRV_CTX_init() sets in the given I<srv_ctx> a custom server context
  95. pointer as well as callback functions performing the specific processing of CMP
  96. certificate requests, revocation requests, certificate confirmation requests,
  97. general messages, error messages, and poll requests.
  98. All arguments except I<srv_ctx> may be NULL.
  99. If a callback for some message type is not given this means that the respective
  100. type of CMP message is not supported by the server.
  101. OSSL_CMP_SRV_CTX_get0_cmp_ctx() returns the B<OSSL_CMP_CTX> from the I<srv_ctx>.
  102. OSSL_CMP_SRV_CTX_get0_custom_ctx() returns the custom server context from
  103. I<srv_ctx> that has been set using OSSL_CMP_SRV_CTX_init().
  104. OSSL_CMP_SRV_CTX_set_send_unprotected_errors() enables sending error messages
  105. and other forms of negative responses unprotected.
  106. OSSL_CMP_SRV_CTX_set_accept_unprotected() enables acceptance of requests
  107. without protection of with invalid protection.
  108. OSSL_CMP_SRV_CTX_set_accept_raverified() enables acceptance of ir/cr/kur
  109. messages with POPO 'RAVerified'.
  110. OSSL_CMP_SRV_CTX_set_grant_implicit_confirm() enables granting implicit
  111. confirmation of newly enrolled certificates if requested.
  112. =head1 NOTES
  113. CMP is defined in RFC 4210 (and CRMF in RFC 4211).
  114. So far the CMP server implementation is limited to one request per CMP message
  115. (and consequently to at most one response component per CMP message).
  116. =head1 RETURN VALUES
  117. OSSL_CMP_SRV_CTX_new() returns a B<OSSL_CMP_SRV_CTX> structure on success,
  118. NULL on error.
  119. OSSL_CMP_SRV_CTX_free() does not return a value.
  120. OSSL_CMP_SRV_CTX_get0_cmp_ctx() returns a B<OSSL_CMP_CTX> structure on success,
  121. NULL on error.
  122. OSSL_CMP_SRV_CTX_get0_custom_ctx() returns the custom server context
  123. that has been set using OSSL_CMP_SRV_CTX_init().
  124. All other functions return 1 on success, 0 on error.
  125. =head1 HISTORY
  126. The OpenSSL CMP support was added in OpenSSL 3.0.
  127. =head1 COPYRIGHT
  128. Copyright 2007-2021 The OpenSSL Project Authors. All Rights Reserved.
  129. Licensed under the Apache License 2.0 (the "License"). You may not use
  130. this file except in compliance with the License. You can obtain a copy
  131. in the file LICENSE in the source distribution or at
  132. L<https://www.openssl.org/source/license.html>.
  133. =cut