File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -352,3 +352,30 @@ vector<X509Cert> ConfV5::TSCerts() const
352352{
353353 return {};
354354}
355+
356+ /* *
357+ * @class digidoc::ConfV6
358+ * @brief Verison 6 of configuration class to add additonial parameters.
359+ *
360+ * Conf contains virtual members and is not leaf class we need create
361+ * subclasses to keep binary compatibility
362+ * https://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++#Adding_new_virtual_functions_to_leaf_classes
363+ * @see digidoc::ConfV5
364+ * @see @ref parameters
365+ */
366+ /* *
367+ * Version 6 config with new parameters
368+ */
369+ ConfV6::ConfV6 () = default;
370+
371+ ConfV6::~ConfV6 () = default ;
372+
373+ /* *
374+ * @copydoc digidoc::Conf::instance()
375+ */
376+ ConfV6* ConfV6::instance () { return dynamic_cast <ConfV6*>(Conf::instance ()); }
377+
378+ /* *
379+ * Gets signing certificate ignoring parameter
380+ */
381+ bool ConfV6::validateSigningCert () const { return true ; }
Original file line number Diff line number Diff line change @@ -126,6 +126,20 @@ class DIGIDOCPP_EXPORT ConfV5: public ConfV4
126126 DISABLE_COPY (ConfV5);
127127};
128128
129- using ConfCurrent = ConfV5;
129+ class DIGIDOCPP_EXPORT ConfV6: public ConfV5
130+ {
131+ public:
132+ ConfV6 ();
133+ ~ConfV6 () override ;
134+ static ConfV6* instance ();
135+
136+ virtual bool validateSigningCert () const ;
137+
138+ private:
139+ DISABLE_COPY (ConfV6);
140+ };
141+
142+ using ConfCurrent = ConfV6;
130143#define CONF (method ) (ConfCurrent::instance() ? ConfCurrent::instance()->method () : ConfCurrent().method())
131144}
145+
Original file line number Diff line number Diff line change 2020#include < SignatureCAdES_B.h>
2121#include < SignatureCAdES_p.h>
2222
23+ #include " Conf.h"
24+
2325#include < crypto/Digest.h>
2426#include < crypto/OpenSSLHelpers.h>
2527#include < crypto/Signer.h>
@@ -178,8 +180,11 @@ void SignatureCAdES_B::validate(const string &policy) const
178180 string time = trustedSigningTime ();
179181 if (time.empty ())
180182 THROW (" SigningTime missing" );
181- if (!X509CertStore::instance ()->verify (signingCertificate (), policy == POLv1))
182- THROW (" Unable to verify signing certificate" );
183+ if (CONF (validateSigningCert))
184+ {
185+ if (!X509CertStore::instance ()->verify (signingCertificate (), policy == POLv1))
186+ THROW (" Unable to verify signing certificate" );
187+ }
183188 } catch (const Exception &e) {
184189 exception.addCause (e);
185190 }
Original file line number Diff line number Diff line change @@ -546,8 +546,11 @@ void SignatureXAdES_B::validate(const string &policy) const
546546 try { checkKeyInfo (); }
547547 catch (const Exception& e) { exception.addCause (e); }
548548
549- try { checkSigningCertificate (policy == POLv1); }
550- catch (const Exception& e) { exception.addCause (e); }
549+ if (CONF (validateSigningCert))
550+ {
551+ try { checkSigningCertificate (policy == POLv1); }
552+ catch (const Exception& e) { exception.addCause (e); }
553+ }
551554 } catch (const Exception &e) {
552555 exception.addCause (e);
553556 } catch (...) {
Original file line number Diff line number Diff line change 2020#include " SignatureXAdES_T.h"
2121
2222#include " ASiC_E.h"
23+ #include " Conf.h"
2324#include " crypto/Digest.h"
2425#include " crypto/OCSP.h"
2526#include " crypto/Signer.h"
@@ -114,8 +115,11 @@ void SignatureXAdES_T::validate(const std::string &policy) const
114115 signatures->c14n (digest, canonicalizationMethod, signatureValue ());
115116 });
116117
117- if (!X509CertStore::instance ()->verify (signingCertificate (), policy == POLv1, tsa.time ()))
118- THROW (" Signing certificate was not valid on signing time" );
118+ if (CONF (validateSigningCert))
119+ {
120+ if (!X509CertStore::instance ()->verify (signingCertificate (), policy == POLv1, tsa.time ()))
121+ THROW (" Signing certificate was not valid on signing time" );
122+ }
119123
120124 auto completeCertRefs = usp/" CompleteCertificateRefs" ;
121125 if (completeCertRefs + 1 )
You can’t perform that action at this time.
0 commit comments