1CMS_VERIFY(3ossl)                   OpenSSL                  CMS_VERIFY(3ossl)
2
3
4

NAME

6       CMS_verify, CMS_get0_signers - verify a CMS SignedData structure
7

SYNOPSIS

9        #include <openssl/cms.h>
10
11        int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, X509_STORE *store,
12                       BIO *indata, BIO *out, unsigned int flags);
13
14        STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);
15

DESCRIPTION

17       CMS_verify() is very similar to PKCS7_verify(3). It verifies a CMS
18       SignedData structure contained in a structure of type CMS_ContentInfo.
19       cms points to the CMS_ContentInfo structure to verify.  The optional
20       certs parameter refers to a set of certificates in which to search for
21       signing certificates.  cms may contain extra untrusted CA certificates
22       that may be used for chain building as well as CRLs that may be used
23       for certificate validation.  store may be NULL or point to the trusted
24       certificate store to use for chain verification.  indata refers to the
25       signed data if the content is detached from cms.  Otherwise indata
26       should be NULL and the signed data must be in cms.  The content is
27       written to the BIO out unless it is NULL.  flags is an optional set of
28       flags, which can be used to modify the operation.
29
30       CMS_get0_signers() retrieves the signing certificate(s) from cms, it
31       may only be called after a successful CMS_verify() operation.
32

VERIFY PROCESS

34       Normally the verify process proceeds as follows.
35
36       Initially some sanity checks are performed on cms. The type of cms must
37       be SignedData. There must be at least one signature on the data and if
38       the content is detached indata cannot be NULL.
39
40       An attempt is made to locate all the signing certificate(s), first
41       looking in the certs parameter (if it is not NULL) and then looking in
42       any certificates contained in the cms structure unless CMS_NOINTERN is
43       set.  If any signing certificate cannot be located the operation fails.
44
45       Each signing certificate is chain verified using the smimesign purpose
46       and using the trusted certificate store store if supplied.  Any
47       internal certificates in the message, which may have been added using
48       CMS_add1_cert(3), are used as untrusted CAs.  If CRL checking is
49       enabled in store and CMS_NOCRL is not set, any internal CRLs, which may
50       have been added using CMS_add1_crl(3), are used in addition to
51       attempting to look them up in store.  If store is not NULL and any
52       chain verify fails an error code is returned.
53
54       Finally the signed content is read (and written to out unless it is
55       NULL) and the signature is checked.
56
57       If all signatures verify correctly then the function is successful.
58
59       Any of the following flags (ored together) can be passed in the flags
60       parameter to change the default verify behaviour.
61
62       If CMS_NOINTERN is set the certificates in the message itself are not
63       searched when locating the signing certificate(s).  This means that all
64       the signing certificates must be in the certs parameter.
65
66       If CMS_NOCRL is set and CRL checking is enabled in store then any CRLs
67       in the message itself are ignored.
68
69       If the CMS_TEXT flag is set MIME headers for type text/plain are
70       deleted from the content. If the content is not of type text/plain then
71       an error is returned.
72
73       If CMS_NO_SIGNER_CERT_VERIFY is set the signing certificates are not
74       chain verified, unless CMS_CADES flag is also set.
75
76       If CMS_NO_ATTR_VERIFY is set the signed attributes signature is not
77       verified, unless CMS_CADES flag is also set.
78
79       If CMS_CADES is set, each signer certificate is checked against the ESS
80       signingCertificate or ESS signingCertificateV2 extension that is
81       required in the signed attributes of the signature.
82
83       If CMS_NO_CONTENT_VERIFY is set then the content digest is not checked.
84

NOTES

86       One application of CMS_NOINTERN is to only accept messages signed by a
87       small number of certificates. The acceptable certificates would be
88       passed in the certs parameter. In this case if the signer certificate
89       is not one of the certificates supplied in certs then the verify will
90       fail because the signer cannot be found.
91
92       In some cases the standard techniques for looking up and validating
93       certificates are not appropriate: for example an application may wish
94       to lookup certificates in a database or perform customised
95       verification. This can be achieved by setting and verifying the signer
96       certificates manually using the signed data utility functions.
97
98       Care should be taken when modifying the default verify behaviour, for
99       example setting CMS_NO_CONTENT_VERIFY will totally disable all content
100       verification and any modified content will be considered valid. This
101       combination is however useful if one merely wishes to write the content
102       to out and its validity is not considered important.
103
104       Chain verification should arguably be performed using the signing time
105       rather than the current time. However, since the signing time is
106       supplied by the signer it cannot be trusted without additional evidence
107       (such as a trusted timestamp).
108

RETURN VALUES

110       CMS_verify() returns 1 for a successful verification and 0 if an error
111       occurred.
112
113       CMS_get0_signers() returns all signers or NULL if an error occurred.
114
115       The error can be obtained from ERR_get_error(3)
116

BUGS

118       The trusted certificate store is not searched for the signing
119       certificate.  This is primarily due to the inadequacies of the current
120       X509_STORE functionality.
121
122       The lack of single pass processing means that the signed content must
123       all be held in memory if it is not detached.
124

SEE ALSO

126       PKCS7_verify(3), CMS_add1_cert(3), CMS_add1_crl(3),
127       OSSL_ESS_check_signing_certs(3), ERR_get_error(3), CMS_sign(3)
128
130       Copyright 2008-2022 The OpenSSL Project Authors. All Rights Reserved.
131
132       Licensed under the Apache License 2.0 (the "License").  You may not use
133       this file except in compliance with the License.  You can obtain a copy
134       in the file LICENSE in the source distribution or at
135       <https://www.openssl.org/source/license.html>.
136
137
138
1393.0.9                             2023-07-27                 CMS_VERIFY(3ossl)
Impressum