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

NAME

6       PKCS7_verify, PKCS7_get0_signers - verify a PKCS#7 signedData structure
7

SYNOPSIS

9        #include <openssl/pkcs7.h>
10
11        int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
12                         BIO *indata, BIO *out, int flags);
13
14        STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags);
15

DESCRIPTION

17       PKCS7_verify() is very similar to CMS_verify(3).  It verifies a PKCS#7
18       signedData structure given in p7.  The optional certs parameter refers
19       to a set of certificates in which to search for signer's certificates.
20       p7 may contain extra untrusted CA certificates that may be used for
21       chain building as well as CRLs that may be used for certificate
22       validation.  store may be NULL or point to the trusted certificate
23       store to use for chain verification.  indata refers to the signed data
24       if the content is detached from p7.  Otherwise indata should be NULL,
25       and then the signed data must be in p7.  The content is written to the
26       BIO out unless it is NULL.  flags is an optional set of flags, which
27       can be used to modify the operation.
28
29       PKCS7_get0_signers() retrieves the signer's certificates from p7, it
30       does not check their validity or whether any signatures are valid. The
31       certs and flags parameters have the same meanings as in PKCS7_verify().
32

VERIFY PROCESS

34       Normally the verify process proceeds as follows.
35
36       Initially some sanity checks are performed on p7. The type of p7 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.  If the content is not
39       detached and indata is not NULL then the structure has both embedded
40       and external content. To treat this as an error, use the flag
41       PKCS7_NO_DUAL_CONTENT.  The default behavior allows this, for
42       compatibility with older versions of OpenSSL.
43
44       An attempt is made to locate all the signer's certificates, first
45       looking in the certs parameter (if it is not NULL). Then they are
46       looked up in any certificates contained in the p7 structure unless
47       PKCS7_NOINTERN is set.  If any signer's certificates cannot be located
48       the operation fails.
49
50       Each signer's certificate is chain verified using the smimesign purpose
51       and using the trusted certificate store store if supplied.  Any
52       internal certificates in the message, which may have been added using
53       PKCS7_add_certificate(3), are used as untrusted CAs unless
54       PKCS7_NOCHAIN is set.  If CRL checking is enabled in store and
55       PKCS7_NOCRL is not set, any internal CRLs, which may have been added
56       using PKCS7_add_crl(3), are used in addition to attempting to look them
57       up in store.  If store is not NULL and any chain verify fails an error
58       code is returned.
59
60       Finally the signed content is read (and written to out unless it is
61       NULL) and the signature is checked.
62
63       If all signatures verify correctly then the function is successful.
64
65       Any of the following flags (ored together) can be passed in the flags
66       parameter to change the default verify behaviour.  Only the flag
67       PKCS7_NOINTERN is meaningful to PKCS7_get0_signers().
68
69       If PKCS7_NOINTERN is set the certificates in the message itself are not
70       searched when locating the signer's certificates.  This means that all
71       the signer's certificates must be in the certs parameter.
72
73       If PKCS7_NOCRL is set and CRL checking is enabled in store then any
74       CRLs in the message itself are ignored.
75
76       If the PKCS7_TEXT flag is set MIME headers for type "text/plain" are
77       deleted from the content. If the content is not of type "text/plain"
78       then an error is returned.
79
80       If PKCS7_NOVERIFY is set the signer's certificates are not chain
81       verified.
82
83       If PKCS7_NOCHAIN is set then the certificates contained in the message
84       are not used as untrusted CAs. This means that the whole verify chain
85       (apart from the signer's certificates) must be contained in the trusted
86       store.
87
88       If PKCS7_NOSIGS is set then the signatures on the data are not checked.
89

NOTES

91       One application of PKCS7_NOINTERN is to only accept messages signed by
92       a small number of certificates. The acceptable certificates would be
93       passed in the certs parameter. In this case if the signer's certificate
94       is not one of the certificates supplied in certs then the verify will
95       fail because the signer cannot be found.
96
97       Care should be taken when modifying the default verify behaviour, for
98       example setting "PKCS7_NOVERIFY|PKCS7_NOSIGS" will totally disable all
99       verification and any signed message will be considered valid. This
100       combination is however useful if one merely wishes to write the content
101       to out and its validity is not considered important.
102
103       Chain verification should arguably be performed using the signing time
104       rather than the current time. However, since the signing time is
105       supplied by the signer it cannot be trusted without additional evidence
106       (such as a trusted timestamp).
107

RETURN VALUES

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

BUGS

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

SEE ALSO

125       CMS_verify(3), PKCS7_add_certificate(3), PKCS7_add_crl(3),
126       ERR_get_error(3), PKCS7_sign(3)
127
129       Copyright 2002-2022 The OpenSSL Project Authors. All Rights Reserved.
130
131       Licensed under the Apache License 2.0 (the "License").  You may not use
132       this file except in compliance with the License.  You can obtain a copy
133       in the file LICENSE in the source distribution or at
134       <https://www.openssl.org/source/license.html>.
135
136
137
1383.0.9                             2023-07-27               PKCS7_VERIFY(3ossl)
Impressum