Use p11_kit_strerror in logError
authorAki Tuomi <cmouse@cmouse.fi>
Mon, 30 Mar 2015 19:31:24 +0000 (22:31 +0300)
committerAki Tuomi <cmouse@cmouse.fi>
Mon, 30 Mar 2015 19:32:43 +0000 (22:32 +0300)
pdns/pkcs11signers.cc

index 2e976c831208662b065ce85b92695362e416549e..ace7eab17d9db32ad2aecaa04d747280e3a3a627 100644 (file)
@@ -7,6 +7,7 @@
 #include <boost/assign/list_of.hpp>
 #include <boost/make_shared.hpp>
 #include <boost/foreach.hpp>
+#include <boost/format.hpp>
 #include <p11-kit/p11-kit.h>
 
 #include "pdns/dnssecinfra.hh"
@@ -208,7 +209,8 @@ class Pkcs11Slot {
 
     void logError(const std::string& operation) const {
       if (d_err) {
-        L<<Logger::Error<<"PKCS#11 operation " << operation << " failed: " << d_err << endl;
+        std::string msg = boost::str( boost::format("PKCS#11 operation %s failed: %s (0x%X)") % operation % p11_kit_strerror(d_err) % d_err );
+        L<<Logger::Error<< msg << endl;
       }
     }
   public:
@@ -280,9 +282,10 @@ class Pkcs11Token {
 
     void logError(const std::string& operation) const {
       if (d_err) {
-        L<<Logger::Error<<"PKCS#11 operation " << operation << " failed: " << d_err << endl;
+        std::string msg = boost::str( boost::format("PKCS#11 operation %s failed: %s (0x%X)") % operation % p11_kit_strerror(d_err) % d_err );
+        L<<Logger::Error<< msg << endl;
       }
-    };
+    }
 
   public:
     Pkcs11Token(const boost::shared_ptr<Pkcs11Slot>& slot, const std::string& label);