Skip to content

Commit

Permalink
Fix --tsurl parameter handling (#666)
Browse files Browse the repository at this point in the history
IB-8410

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma authored Mar 4, 2025
1 parent 2b576dc commit dd315aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/crypto/Connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <zlib.h>

#include <chrono>
#include <sstream>
#include <thread>

Expand Down
21 changes: 8 additions & 13 deletions src/digidoc-tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ ToolConfig::ToolConfig(int argc, char *argv[])
else if(arg == "--sigpsssha512") { siguri = URI_SHA512; rsaPss = true; }
else if(arg == "--rsapkcs15") rsaPss = false;
else if(arg == "--rsapss") rsaPss = true;
else if(value v{arg, "--tsurl"}) tsurl = v;
else if(value v{arg, "--tsurl="}) tsurl = v;
else if(value v{arg, "--tslurl="}) tslurl = v;
else if(value v{arg, "--tslcert="}) tslcerts = vector<X509Cert>{ X509Cert(v) };
else if(arg == "--TSLAllowExpired") expired = true;
Expand Down Expand Up @@ -512,6 +512,12 @@ unique_ptr<Signer> ToolConfig::getSigner(bool getwebsigner) const
return signer;
}

/**
* Validate signature.
*
* @param signature Signature to validated
* @return EXIT_FAILURE (1) - failure, EXIT_SUCCESS (0) - success
*/
static int validateSignature(const Signature *s, ToolConfig::Warning warning = ToolConfig::WWarning)
{
int returnCode = EXIT_SUCCESS;
Expand Down Expand Up @@ -782,18 +788,7 @@ static int add(const ToolConfig &p, const char *program)
static int signContainer(Container *doc, const unique_ptr<Signer> &signer, bool dontValidate = false)
{
if(Signature *signature = doc->sign(signer.get()))
{
if(dontValidate)
return EXIT_SUCCESS;
try {
signature->validate();
cout << " Validation: " << ToolConfig::GREEN << "OK" << ToolConfig::RESET << endl;
return EXIT_SUCCESS;
} catch(const Exception &e) {
cout << " Validation: " << ToolConfig::RED << "FAILED" << ToolConfig::RESET << endl;
cout << " Exception:" << endl << e;
}
}
return dontValidate ? EXIT_SUCCESS : validateSignature(signature);
return EXIT_FAILURE;
}

Expand Down

0 comments on commit dd315aa

Please sign in to comment.