More OS X debug.
[dcpomatic.git] / src / lib / util.cc
index e0495f18b495e5e16eb0e828e8318f765d455aa9..b9075310308442901452beb0e0a86d00967c6758 100644 (file)
@@ -69,6 +69,9 @@ extern "C" {
 #ifdef DCPOMATIC_WINDOWS
 #include "stack.hpp"
 #endif
+#ifdef DCPOMATIC_OSX
+#include <ltdl.h>
+#endif
 
 #include "i18n.h"
 
@@ -279,6 +282,16 @@ dcpomatic_setup ()
        
        avfilter_register_all ();
 
+#ifdef DCPOMATIC_OSX
+       /* Add our lib directory to the libltdl search path so that
+          xmlsec can find xmlsec1-openssl.
+       */
+       boost::filesystem::path lib = app_contents ();
+       lib /= "lib";
+       std::cout << "adding search dir " << lib.c_str() << "\n";
+       lt_dladdsearchdir (lib.c_str ());
+#endif 
+
        libdcp::init ();
        
        Ratio::setup_ratios ();
@@ -824,10 +837,29 @@ shared_ptr<const libdcp::Signer>
 make_signer ()
 {
        boost::filesystem::path const sd = Config::instance()->signer_chain_directory ();
-       if (boost::filesystem::is_empty (sd)) {
-               libdcp::make_signer_chain (sd, openssl_path ());
-       }
 
+       /* Remake the chain if any of it is missing */
+       
+       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);
+               p /= *i;
+               if (!boost::filesystem::exists (p)) {
+                       boost::filesystem::remove_all (sd);
+                       boost::filesystem::create_directories (sd);
+                       libdcp::make_signer_chain (sd, openssl_path ());
+                       break;
+               }
+
+               ++i;
+       }
+       
        libdcp::CertificateChain chain;
 
        {