diff options
Diffstat (limited to 'Swift/Controllers/Storages/CertificateFileStorage.cpp')
-rw-r--r-- | Swift/Controllers/Storages/CertificateFileStorage.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Swift/Controllers/Storages/CertificateFileStorage.cpp b/Swift/Controllers/Storages/CertificateFileStorage.cpp index 3fe6d54..a8661df 100644 --- a/Swift/Controllers/Storages/CertificateFileStorage.cpp +++ b/Swift/Controllers/Storages/CertificateFileStorage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -31,7 +31,7 @@ bool CertificateFileStorage::hasCertificate(Certificate::ref certificate) const return true; } else { - SWIFT_LOG(warning) << "Stored certificate does not match received certificate" << std::endl; + SWIFT_LOG(warning) << "Stored certificate does not match received certificate"; return false; } } @@ -50,10 +50,15 @@ void CertificateFileStorage::addCertificate(Certificate::ref certificate) { 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; + } } boost::filesystem::path CertificateFileStorage::getCertificatePath(Certificate::ref certificate) const { |