summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers/Storages')
-rw-r--r--Swift/Controllers/Storages/CertificateFileStorage.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/Swift/Controllers/Storages/CertificateFileStorage.cpp b/Swift/Controllers/Storages/CertificateFileStorage.cpp
index 3fe6d54..2e1343f 100644
--- a/Swift/Controllers/Storages/CertificateFileStorage.cpp
+++ b/Swift/Controllers/Storages/CertificateFileStorage.cpp
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swift/Controllers/Storages/CertificateFileStorage.h>
#include <iostream>
#include <boost/filesystem/fstream.hpp>
@@ -44,20 +44,25 @@ void CertificateFileStorage::addCertificate(Certificate::ref certificate) {
boost::filesystem::path certificatePath = getCertificatePath(certificate);
if (!boost::filesystem::exists(certificatePath.parent_path())) {
try {
boost::filesystem::create_directories(certificatePath.parent_path());
}
catch (const boost::filesystem::filesystem_error& e) {
std::cerr << "ERROR: " << e.what() << std::endl;
}
}
- boost::filesystem::ofstream file(certificatePath, boost::filesystem::ofstream::binary|boost::filesystem::ofstream::out);
- ByteArray data = certificate->toDER();
- file.write(reinterpret_cast<const char*>(vecptr(data)), boost::numeric_cast<std::streamsize>(data.size()));
- file.close();
+ try {
+ boost::filesystem::ofstream file(certificatePath, boost::filesystem::ofstream::binary|boost::filesystem::ofstream::out);
+ ByteArray data = certificate->toDER();
+ file.write(reinterpret_cast<const char*>(vecptr(data)), boost::numeric_cast<std::streamsize>(data.size()));
+ file.close();
+ }
+ catch (...) {
+ SWIFT_LOG(warning) << "Failed to store certificate to " << certificatePath << std::endl;
+ }
}
boost::filesystem::path CertificateFileStorage::getCertificatePath(Certificate::ref certificate) const {
return path / Hexify::hexify(crypto->getSHA1Hash(certificate->toDER()));
}
}