CMS_verify.pod 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. =pod
  2. =head1 NAME
  3. CMS_verify, CMS_get0_signers - verify a CMS SignedData structure
  4. =head1 SYNOPSIS
  5. #include <openssl/cms.h>
  6. int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store,
  7. BIO *indata, BIO *out, unsigned int flags);
  8. STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);
  9. =head1 DESCRIPTION
  10. CMS_verify() verifies a CMS SignedData structure. B<cms> is the CMS_ContentInfo
  11. structure to verify. B<certs> is a set of certificates in which to search for
  12. the signing certificate(s). B<store> is a trusted certificate store used for
  13. chain verification. B<indata> is the detached content if the content is not
  14. present in B<cms>. The content is written to B<out> if it is not NULL.
  15. B<flags> is an optional set of flags, which can be used to modify the verify
  16. operation.
  17. CMS_get0_signers() retrieves the signing certificate(s) from B<cms>, it may only
  18. be called after a successful CMS_verify() operation.
  19. =head1 VERIFY PROCESS
  20. Normally the verify process proceeds as follows.
  21. Initially some sanity checks are performed on B<cms>. The type of B<cms> must
  22. be SignedData. There must be at least one signature on the data and if
  23. the content is detached B<indata> cannot be B<NULL>.
  24. An attempt is made to locate all the signing certificate(s), first looking in
  25. the B<certs> parameter (if it is not NULL) and then looking in any
  26. certificates contained in the B<cms> structure itself. If any signing
  27. certificate cannot be located the operation fails.
  28. Each signing certificate is chain verified using the B<smimesign> purpose and
  29. the supplied trusted certificate store. Any internal certificates in the message
  30. are used as untrusted CAs. If CRL checking is enabled in B<store> any internal
  31. CRLs are used in addition to attempting to look them up in B<store>. If any
  32. chain verify fails an error code is returned.
  33. Finally the signed content is read (and written to B<out> if it is not NULL)
  34. and the signature's checked.
  35. If all signature's verify correctly then the function is successful.
  36. Any of the following flags (ored together) can be passed in the B<flags>
  37. parameter to change the default verify behaviour.
  38. If B<CMS_NOINTERN> is set the certificates in the message itself are not
  39. searched when locating the signing certificate(s). This means that all the
  40. signing certificates must be in the B<certs> parameter.
  41. If B<CMS_NOCRL> is set and CRL checking is enabled in B<store> then any
  42. CRLs in the message itself are ignored.
  43. If the B<CMS_TEXT> flag is set MIME headers for type B<text/plain> are deleted
  44. from the content. If the content is not of type B<text/plain> then an error is
  45. returned.
  46. If B<CMS_NO_SIGNER_CERT_VERIFY> is set the signing certificates are not
  47. verified, unless CMS_CADES flag is also set.
  48. If B<CMS_NO_ATTR_VERIFY> is set the signed attributes signature is not
  49. verified, unless CMS_CADES flag is also set.
  50. If B<CMS_CADES> is set, each signer certificate is checked against the
  51. "ESS signing-certificate" extension added in the signed attributes of the
  52. signature.
  53. If B<CMS_NO_CONTENT_VERIFY> is set then the content digest is not checked.
  54. =head1 NOTES
  55. One application of B<CMS_NOINTERN> is to only accept messages signed by
  56. a small number of certificates. The acceptable certificates would be passed
  57. in the B<certs> parameter. In this case if the signer is not one of the
  58. certificates supplied in B<certs> then the verify will fail because the
  59. signer cannot be found.
  60. In some cases the standard techniques for looking up and validating
  61. certificates are not appropriate: for example an application may wish to
  62. lookup certificates in a database or perform customised verification. This
  63. can be achieved by setting and verifying the signers certificates manually
  64. using the signed data utility functions.
  65. Care should be taken when modifying the default verify behaviour, for example
  66. setting B<CMS_NO_CONTENT_VERIFY> will totally disable all content verification
  67. and any modified content will be considered valid. This combination is however
  68. useful if one merely wishes to write the content to B<out> and its validity
  69. is not considered important.
  70. Chain verification should arguably be performed using the signing time rather
  71. than the current time. However, since the signing time is supplied by the
  72. signer it cannot be trusted without additional evidence (such as a trusted
  73. timestamp).
  74. =head1 RETURN VALUES
  75. CMS_verify() returns 1 for a successful verification and zero if an error
  76. occurred.
  77. CMS_get0_signers() returns all signers or NULL if an error occurred.
  78. The error can be obtained from L<ERR_get_error(3)>
  79. =head1 BUGS
  80. The trusted certificate store is not searched for the signing certificate,
  81. this is primarily due to the inadequacies of the current B<X509_STORE>
  82. functionality.
  83. The lack of single pass processing means that the signed content must all
  84. be held in memory if it is not detached.
  85. =head1 SEE ALSO
  86. L<ERR_get_error(3)>, L<CMS_sign(3)>
  87. =head1 COPYRIGHT
  88. Copyright 2008-2020 The OpenSSL Project Authors. All Rights Reserved.
  89. Licensed under the Apache License 2.0 (the "License"). You may not use
  90. this file except in compliance with the License. You can obtain a copy
  91. in the file LICENSE in the source distribution or at
  92. L<https://www.openssl.org/source/license.html>.
  93. =cut