Skip to content

Commit dd315aa

Browse files
authored
Fix --tsurl parameter handling (#666)
IB-8410 Signed-off-by: Raul Metsma <[email protected]>
1 parent 2b576dc commit dd315aa

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/crypto/Connect.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include <zlib.h>
3232

33+
#include <chrono>
3334
#include <sstream>
3435
#include <thread>
3536

src/digidoc-tool.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ ToolConfig::ToolConfig(int argc, char *argv[])
454454
else if(arg == "--sigpsssha512") { siguri = URI_SHA512; rsaPss = true; }
455455
else if(arg == "--rsapkcs15") rsaPss = false;
456456
else if(arg == "--rsapss") rsaPss = true;
457-
else if(value v{arg, "--tsurl"}) tsurl = v;
457+
else if(value v{arg, "--tsurl="}) tsurl = v;
458458
else if(value v{arg, "--tslurl="}) tslurl = v;
459459
else if(value v{arg, "--tslcert="}) tslcerts = vector<X509Cert>{ X509Cert(v) };
460460
else if(arg == "--TSLAllowExpired") expired = true;
@@ -512,6 +512,12 @@ unique_ptr<Signer> ToolConfig::getSigner(bool getwebsigner) const
512512
return signer;
513513
}
514514

515+
/**
516+
* Validate signature.
517+
*
518+
* @param signature Signature to validated
519+
* @return EXIT_FAILURE (1) - failure, EXIT_SUCCESS (0) - success
520+
*/
515521
static int validateSignature(const Signature *s, ToolConfig::Warning warning = ToolConfig::WWarning)
516522
{
517523
int returnCode = EXIT_SUCCESS;
@@ -782,18 +788,7 @@ static int add(const ToolConfig &p, const char *program)
782788
static int signContainer(Container *doc, const unique_ptr<Signer> &signer, bool dontValidate = false)
783789
{
784790
if(Signature *signature = doc->sign(signer.get()))
785-
{
786-
if(dontValidate)
787-
return EXIT_SUCCESS;
788-
try {
789-
signature->validate();
790-
cout << " Validation: " << ToolConfig::GREEN << "OK" << ToolConfig::RESET << endl;
791-
return EXIT_SUCCESS;
792-
} catch(const Exception &e) {
793-
cout << " Validation: " << ToolConfig::RED << "FAILED" << ToolConfig::RESET << endl;
794-
cout << " Exception:" << endl << e;
795-
}
796-
}
791+
return dontValidate ? EXIT_SUCCESS : validateSignature(signature);
797792
return EXIT_FAILURE;
798793
}
799794

0 commit comments

Comments
 (0)