#include <magick/version.h>
#include <libdcp/version.h>
#include <libdcp/util.h>
+#include <libdcp/signer_chain.h>
+#include <libdcp/signer.h>
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libpostproc/postprocess.h>
#include <libavutil/pixfmt.h>
}
-#include <curl/curl.h>
#include "util.h"
#include "exceptions.h"
#include "scaler.h"
#include "config.h"
#include "ratio.h"
#include "job.h"
+#include "cross.h"
#ifdef DCPOMATIC_WINDOWS
#include "stack.hpp"
#endif
return t;
}
-struct EmailState
+shared_ptr<const libdcp::Signer>
+make_signer ()
{
- string message;
- int done;
-};
+ boost::filesystem::path const sd = Config::instance()->signer_chain_directory ();
-static size_t
-send_email_function (void* ptr, size_t size, size_t nmemb, void* userdata)
-{
- EmailState* state = reinterpret_cast<EmailState*> (userdata);
-
- int const now = min (size * nmemb, state->message.length() - state->done);
-
- memcpy (ptr, state->message.c_str() + state->done, now);
- state->done += now;
-
- return now;
-}
+ /* Remake the chain if any of it is missing */
-bool
-send_email (string from, string to, string message)
-{
- CURL* curl = curl_easy_init ();
- if (!curl) {
- return true;
- }
+ list<boost::filesystem::path> files;
+ files.push_back ("ca.self-signed.pem");
+ files.push_back ("intermediate.signed.pem");
+ files.push_back ("leaf.signed.pem");
+ files.push_back ("leaf.key");
+
+ list<boost::filesystem::path>::const_iterator i = files.begin();
+ while (i != files.end()) {
+ boost::filesystem::path p (sd);
+ sd /= *i;
+ if (!boost::filesystem::exists (sd)) {
+ boost::filesystem::remove_all (sd);
+ libdcp::make_signer_chain (sd, openssl_path ());
+ break;
+ }
- string const url = "smtp://" + Config::instance()->mail_server();
+ ++i;
+ }
+
+ libdcp::CertificateChain chain;
- curl_easy_setopt (curl, CURLOPT_URL, url.c_str ());
- curl_easy_setopt (curl, CURLOPT_MAIL_FROM, from.c_str ());
- struct curl_slist* recipients = 0;
- recipients = curl_slist_append (recipients, to.c_str ());
- curl_easy_setopt (curl, CURLOPT_READFUNCTION, send_email_function);
+ {
+ boost::filesystem::path p (sd);
+ p /= "ca.self-signed.pem";
+ chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p)));
+ }
- EmailState state;
- state.message = message;
- state.done = 0;
- curl_easy_setopt (curl, CURLOPT_READDATA, &state);
+ {
+ boost::filesystem::path p (sd);
+ p /= "intermediate.signed.pem";
+ chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p)));
+ }
- if (curl_easy_perform (curl) != CURLE_OK) {
- return true;
+ {
+ boost::filesystem::path p (sd);
+ p /= "leaf.signed.pem";
+ chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p)));
}
- curl_slist_free_all (recipients);
- curl_easy_cleanup (curl);
+ boost::filesystem::path signer_key (sd);
+ signer_key /= "leaf.key";
- return false;
+ return shared_ptr<const libdcp::Signer> (new libdcp::Signer (chain, signer_key));
}
+