2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
22 * @file xmltooling/security/AbstractPKIXTrustEngine.h
24 * A trust engine that uses X.509 trust anchors and CRLs associated with a peer
25 * to perform PKIX validation of signatures and credentials.
28 #if !defined(__xmltooling_pkixtrust_h__) && !defined(XMLTOOLING_NO_XMLSEC)
29 #define __xmltooling_pkixtrust_h__
31 #include <xmltooling/security/OpenSSLTrustEngine.h>
32 #include <xmltooling/security/SignatureTrustEngine.h>
36 namespace xmltooling {
38 class XMLTOOL_API XSECCryptoX509CRL;
41 * A trust engine that uses X.509 trust anchors and CRLs associated with a peer
42 * to perform PKIX validation of signatures and credentials.
44 class XMLTOOL_API AbstractPKIXTrustEngine : public SignatureTrustEngine, public OpenSSLTrustEngine
50 * If a DOM is supplied, the following XML content is supported:
53 * <li>checkRevocation attribute (off, entityOnly, fullChain)
56 * @param e DOM to supply configuration for provider
58 AbstractPKIXTrustEngine(const xercesc::DOMElement* e=nullptr);
60 /** Controls revocation checking, currently limited to CRLs and supports "off", "entityOnly", "fullChain". */
61 std::string m_checkRevocation;
63 /** Deprecated option, equivalent to checkRevocation="fullChain". */
67 * Checks that either the name of the peer with the given credentials or the names
68 * of the credentials match the subject or subject alternate names of the certificate.
70 * @param certEE the credential for the entity to validate
71 * @param credResolver source of credentials
72 * @param criteria criteria for selecting credentials, including the peer name
74 * @return true the name check succeeds, false if not
76 bool checkEntityNames(X509* certEE, const CredentialResolver& credResolver, const CredentialCriteria& criteria) const;
79 virtual ~AbstractPKIXTrustEngine();
82 xmlsignature::Signature& sig,
83 const CredentialResolver& credResolver,
84 CredentialCriteria* criteria=nullptr
88 const XMLCh* sigAlgorithm,
90 xmlsignature::KeyInfo* keyInfo,
93 const CredentialResolver& credResolver,
94 CredentialCriteria* criteria=nullptr
98 XSECCryptoX509* certEE,
99 const std::vector<XSECCryptoX509*>& certChain,
100 const CredentialResolver& credResolver,
101 CredentialCriteria* criteria=nullptr
106 STACK_OF(X509)* certChain,
107 const CredentialResolver& credResolver,
108 CredentialCriteria* criteria=nullptr
112 * Stateful interface that supplies PKIX validation data to the trust engine.
113 * Applications can adapt this TrustEngine to their environment by returning
114 * implementations of this interface from the getPKIXValidationInfoIterator
117 class XMLTOOL_API PKIXValidationInfoIterator {
118 MAKE_NONCOPYABLE(PKIXValidationInfoIterator);
120 PKIXValidationInfoIterator();
123 virtual ~PKIXValidationInfoIterator();
126 * Advances to the next set of information, if any.
128 * @return true iff another set of information is available
130 virtual bool next()=0;
133 * Returns the allowable trust chain verification depth for the
134 * validation data in the current position.
136 * @return allowable trust chain verification depth
138 virtual int getVerificationDepth() const=0;
141 * Returns the set of trust anchors for the validation data in the
142 * current position. Keeping the certificates beyond the lifetime
143 * of the iterator or after advancing to the next position requires
146 * @return set of trust anchors
148 virtual const std::vector<XSECCryptoX509*>& getTrustAnchors() const=0;
151 * Returns the set of CRLs for the validation data in the
152 * current position. Keeping the CRLs beyond the lifetime
153 * of the iterator or after advancing to the next position requires
156 * @return set of CRLs
158 virtual const std::vector<XSECCryptoX509CRL*>& getCRLs() const=0;
162 * Provides access to the information necessary, for the given credential source, for
163 * PKIX validation of credentials. Each set of validation information returned
164 * will be tried, in turn, until one succeeds or no more remain.
165 * The caller must free the returned interface when finished with it.
167 * @param pkixSource the peer for which validation rules are required
168 * @param criteria criteria for selecting validation rules
169 * @return interface for obtaining validation data
171 virtual PKIXValidationInfoIterator* getPKIXValidationInfoIterator(
172 const CredentialResolver& pkixSource, CredentialCriteria* criteria=nullptr
176 bool validateWithCRLs(
178 STACK_OF(X509)* certChain,
179 const CredentialResolver& credResolver,
180 CredentialCriteria* criteria=nullptr,
181 const std::vector<XSECCryptoX509CRL*>* inlineCRLs=nullptr
186 #endif /* __xmltooling_pkixtrust_h__ */