projects
/
libdcp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix tests.
[libdcp.git]
/
tools
/
dcpkdm.cc
diff --git
a/tools/dcpkdm.cc
b/tools/dcpkdm.cc
index 9fb35d128507b8c1e3a43c7e39c92597d5ee312d..d8a10fa35eae8058684b41cffee29787c629d7c4 100644
(file)
--- a/
tools/dcpkdm.cc
+++ b/
tools/dcpkdm.cc
@@
-1,5
+1,5
@@
/*
/*
- Copyright (C) 2017-20
19
Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-20
21
Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
This file is part of libdcp.
@@
-31,19
+31,21
@@
files in the program, then also delete it here.
*/
files in the program, then also delete it here.
*/
-#include "encrypted_kdm.h"
+
+#include "certificate_chain.h"
#include "decrypted_kdm.h"
#include "decrypted_kdm.h"
-#include "
util
.h"
+#include "
encrypted_kdm
.h"
#include "exceptions.h"
#include "exceptions.h"
-#include "certificate_chain.h"
-#include <boost/foreach.hpp>
+#include "util.h"
#include <getopt.h>
#include <getopt.h>
-using std::string;
-using std::cout;
+
using std::cerr;
using std::cerr;
+using std::cout;
+using std::string;
using boost::optional;
using boost::optional;
+
static void
help (string n)
{
static void
help (string n)
{
@@
-52,17
+54,13
@@
help (string n)
<< " -p, --private-key private key file\n";
}
<< " -p, --private-key private key file\n";
}
-static string
-tm_to_string (struct tm t)
-{
- char buffer[64];
- snprintf (buffer, 64, "%02d/%02d/%02d %02d:%02d:%02d", t.tm_mday, t.tm_mon, (t.tm_year + 1900), t.tm_hour, t.tm_min, t.tm_sec);
- return buffer;
-}
int
main (int argc, char* argv[])
int
main (int argc, char* argv[])
+try
{
{
+ dcp::init ();
+
optional<boost::filesystem::path> private_key_file;
int option_index = 0;
optional<boost::filesystem::path> private_key_file;
int option_index = 0;
@@
-109,14
+107,14
@@
main (int argc, char* argv[])
cout << "Signer chain:\n";
dcp::CertificateChain signer = enc_kdm.signer_certificate_chain ();
cout << "Signer chain:\n";
dcp::CertificateChain signer = enc_kdm.signer_certificate_chain ();
-
BOOST_FOREACH (dcp::Certificate const & i,
signer.root_to_leaf()) {
+
for (auto const& i:
signer.root_to_leaf()) {
cout << "\tCertificate:\n";
cout << "\t\tSubject: " << i.subject() << "\n";
cout << "\t\tSubject common name: " << i.subject_common_name() << "\n";
cout << "\t\tSubject organization name: " << i.subject_organization_name() << "\n";
cout << "\t\tSubject organizational unit name: " << i.subject_organizational_unit_name() << "\n";
cout << "\tCertificate:\n";
cout << "\t\tSubject: " << i.subject() << "\n";
cout << "\t\tSubject common name: " << i.subject_common_name() << "\n";
cout << "\t\tSubject organization name: " << i.subject_organization_name() << "\n";
cout << "\t\tSubject organizational unit name: " << i.subject_organizational_unit_name() << "\n";
- cout << "\t\tNot before: " <<
tm_to_string(i.not_before()
) << "\n";
- cout << "\t\tNot after: " <<
tm_to_string(i.not_after()
) << "\n";
+ cout << "\t\tNot before: " <<
i.not_before().as_string(
) << "\n";
+ cout << "\t\tNot after: " <<
i.not_after().as_string(
) << "\n";
if (i.has_utf8_strings()) {
cout << "\t\tUSES INCORRECT (UTF8) STRING ENCODING\n";
}
if (i.has_utf8_strings()) {
cout << "\t\tUSES INCORRECT (UTF8) STRING ENCODING\n";
}
@@
-125,11
+123,11
@@
main (int argc, char* argv[])
if (private_key_file) {
try {
dcp::DecryptedKDM dec_kdm (enc_kdm, dcp::file_to_string (private_key_file.get()));
if (private_key_file) {
try {
dcp::DecryptedKDM dec_kdm (enc_kdm, dcp::file_to_string (private_key_file.get()));
- cout << "\nKeys";
-
BOOST_FOREACH (dcp::DecryptedKDMKey i, dec_kdm.keys
()) {
+ cout << "\nKeys
:
";
+
for (auto i: dec_kdm.keys
()) {
cout << "\n";
cout << "\tID: " << i.id() << "\n";
cout << "\n";
cout << "\tID: " << i.id() << "\n";
- cout << "\tStandard: " << (i.standard() == dcp::SMPTE ? "SMPTE" : "Interop") << "\n";
+ cout << "\tStandard: " << (i.standard() == dcp::S
tandard::S
MPTE ? "SMPTE" : "Interop") << "\n";
cout << "\tCPL ID: " << i.cpl_id() << "\n";
if (i.type()) {
cout << "\tType: " << i.type().get() << "\n";
cout << "\tCPL ID: " << i.cpl_id() << "\n";
if (i.type()) {
cout << "\tType: " << i.type().get() << "\n";
@@
-144,3
+142,8
@@
main (int argc, char* argv[])
return 0;
}
return 0;
}
+catch (std::exception& e)
+{
+ cerr << "Error: " << e.what() << "\n";
+ exit (EXIT_FAILURE);
+}