Skip to content

Commit

Permalink
Handle libdigidocpp exception (#943)
Browse files Browse the repository at this point in the history
* Handle libdigidocpp exception

Signed-off-by: Jelena Sanko <jelena@raulwalter.com>

* catch Exception by (const) reference rather than by value

Co-authored-by: Raul Metsma <raul@metsma.ee>

Co-authored-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
jsanko and metsma authored Jul 6, 2021
1 parent a9efe0f commit 18e6112
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions client/SslCertificate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@

#include "Common.h"

#include <digidocpp/Exception.h>
#include <digidocpp/crypto/X509Cert.h>

#include <QtCore/QDataStream>
#include <QtCore/QDateTime>
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QHash>
#include <QtCore/QMap>
Expand Down Expand Up @@ -353,12 +355,16 @@ SslCertificate::CertType SslCertificate::type() const
QByteArray der = toDer();
if (!der.isNull())
{
digidoc::X509Cert x509Cert((const unsigned char*)der.constData(),
size_t(der.size()), digidoc::X509Cert::Der);
for(const std::string &statement: x509Cert.qcStatements())
{
if(statement == digidoc::X509Cert::QCT_ESEAL)
return TempelType;
try {
digidoc::X509Cert x509Cert((const unsigned char*)der.constData(),
size_t(der.size()), digidoc::X509Cert::Der);
for(const std::string &statement: x509Cert.qcStatements())
{
if(statement == digidoc::X509Cert::QCT_ESEAL)
return TempelType;
}
} catch (const digidoc::Exception &e) {
qWarning() << "digidoc::X509Cert error:" << QString::fromStdString(e.msg());
}
}
return UnknownType;
Expand Down

0 comments on commit 18e6112

Please sign in to comment.