CertificateLoader loader;
if (CertificateLoader::NO_ERROR !=
loader.loadCertificateFromRawData(m_parserSchema.getText())) {
+ fprintf(stderr, "## [validate error]: Certificate could not be loaded\n");
LogWarning("Certificate could not be loaded!");
ThrowMsg(ParserSchemaException::CertificateLoaderError,
"Certificate could not be loaded.");
if (CertificateLoader::NO_ERROR !=
loader.loadCertificateBasedOnExponentAndModulus(m_modulus,
m_exponent)) {
+ fprintf(stderr, "## [validate error]: Certificate could not be loaded\n");
LogWarning("Certificate could not be loaded!");
ThrowMsg(ParserSchemaException::CertificateLoaderError,
"Certificate could not be loaded.");
CertificateLoader loader;
if (CertificateLoader::NO_ERROR !=
loader.loadCertificateWithECKEY(m_nameCurveURI, m_publicKey)) {
+ fprintf(stderr, "## [validate error]: Certificate could not be loaded\n");
ThrowMsg(ParserSchemaException::CertificateLoaderError,
"Certificate could not be loaded.");
}
m_dsaKeyJComponent,
m_dsaKeySeedComponent,
m_dsaKeyPGenCounter)) {
+ fprintf(stderr, "## [validate error]: Certificate could not be loaded\n");
LogWarning("Certificate could not be loaded.");
ThrowMsg(ParserSchemaException::CertificateLoaderError,
"Certificate could not be loaded.");
void SignatureReader::tokenRole(SignatureData &signatureData)
{
if (!signatureData.m_roleURI.empty()) {
+ fprintf(stderr, "## [validate error]: Multiple definition of Role is not allowed\n");
LogWarning("Multiple definition of Role is not allowed.");
ThrowMsg(ParserSchemaException::UnsupportedValue,
"Multiple definition of Role is not allowed.");
void SignatureReader::tokenProfile(SignatureData &signatureData)
{
if (!signatureData.m_profileURI.empty()) {
+ fprintf(stderr, "## [validate error]: Multiple definition of Profile is not allowed\n");
LogWarning("Multiple definition of Profile is not allowed.");
ThrowMsg(ParserSchemaException::UnsupportedValue,
"Multiple definition of Profile is not allowed.");
void SignatureReader::tokenEndIdentifier(SignatureData &signatureData)
{
if (!signatureData.m_identifier.empty()) {
+ fprintf(stderr, "## [validate error]: Multiple definition of Identifier is not allowed\n");
LogWarning("Multiple definition of Identifier is not allowed.");
ThrowMsg(ParserSchemaException::UnsupportedValue,
"Multiple definition of Identifier is not allowed.");
std::string id = m_parserSchema.getReader().attribute(TOKEN_ID);
if (id.empty()) {
+ fprintf(stderr, "## [validate error]: Unsupported value of Attribute Id in Object tag\n");
LogWarning("Unsupported value of Attribute Id in Object tag.");
ThrowMsg(ParserSchemaException::UnsupportedValue,
"Unsupported value of Attribute Id in Object tag.");
{
(void)signatureData;
if (++m_signaturePropertiesCounter > 1) {
+ fprintf(stderr, "## [validate error]: Only one SignatureProperties tag is allowed in Object\n");
LogWarning("Only one SignatureProperties tag is allowed in Object");
ThrowMsg(ParserSchemaException::UnsupportedValue,
"Only one SignatureProperties tag is allowed in Object");
#include <xmlsec/crypto.h>
#include <xmlsec/io.h>
#include <xmlsec/keyinfo.h>
+#include <xmlsec/errors.h>
#include <dpl/assert.h>
#include <dpl/log/log.h>
}
}
+void LogDebugPrint(const char* file, int line, const char* func,
+ const char* errorObject, const char* errorSubject,
+ int reason, const char* msg)
+{
+ char total[1024];
+ sprintf(total, "[%s(%d)] : [%s] : [%s] : [%s]", func, line, errorObject, errorSubject, msg);
+
+ if(reason != 256)
+ {
+ fprintf(stderr, "## [validate error]: %s\n", total);
+ LogError(" " << total);
+ }
+ else
+ {
+ LogDebug(" " << total);
+ }
+}
+
XmlSec::XmlSec() :
m_initialized(false)
{
/* Verify signature */
if (xmlSecDSigCtxVerify(dsigCtx, node) < 0) {
- LogWarning("Signature verify error.");
+ LogError("Signature verify error.");
+ fprintf(stderr, "## [validate error]: Signature verify error\n");
+ res = -1;
goto done;
}
res = 0;
} else {
LogDebug("Signature is INVALID");
+ res = -1;
goto done;
}
Assert(!(context->signatureFile.empty()));
Assert(context->certificatePtr.Get() || !(context->certificatePath.empty()));
+ xmlSecErrorsSetCallback(LogDebugPrint);
+
if (!m_initialized) {
LogError("XmlSec is not initialized.");
ThrowMsg(Exception::InternalError, "XmlSec is not initialized");