diff options
| author | Edwin Mons <edwin.mons@isode.com> | 2019-11-19 13:36:05 (GMT) |
|---|---|---|
| committer | Edwin Mons <edwin.mons@isode.com> | 2019-11-19 13:58:45 (GMT) |
| commit | 261ba8d8595ed8cb90f9c4feb1d6ef642942bcba (patch) | |
| tree | c7e60d473509db8c4dbff5aa83fbde963d8dd75e /Swiften/TLS/OpenSSL | |
| parent | 697ae6ae84512a744958b24118197ec7bfdbc1f0 (diff) | |
| download | swift-261ba8d8595ed8cb90f9c4feb1d6ef642942bcba.zip swift-261ba8d8595ed8cb90f9c4feb1d6ef642942bcba.tar.bz2 | |
Remove std::endl from SWIFT_LOG calls
The std::endl is now added by ~Log, but only for output to stderr or a
log file. Calls to the Android logging system or manually set callbacks
will not include the newline in the logging output.
JIRA: SWIFT-430
Test-Information:
Unit tests pass on Debian 9
Checked that running Swift with logging to stderr still had a newline.
Change-Id: I096fdba78a3b8f87db2097951c28c528592183e8
Diffstat (limited to 'Swiften/TLS/OpenSSL')
| -rw-r--r-- | Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp | 4 | ||||
| -rw-r--r-- | Swiften/TLS/OpenSSL/OpenSSLContext.cpp | 24 | ||||
| -rw-r--r-- | Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp | 4 |
3 files changed, 16 insertions, 16 deletions
diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp index 16b0b2b..66b650d 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp @@ -1,8 +1,8 @@ /* - * Copyright (c) 2010-2016 Isode Limited. + * Copyright (c) 2010-2019 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swiften/TLS/OpenSSL/OpenSSLCertificate.h> @@ -29,13 +29,13 @@ OpenSSLCertificate::OpenSSLCertificate(const ByteArray& der) { unsigned char* p = const_cast<unsigned char*>(vecptr(der)); #else const unsigned char* p = vecptr(der); #endif cert = std::shared_ptr<X509>(d2i_X509(nullptr, &p, der.size()), X509_free); if (!cert) { -// SWIFT_LOG(warning) << "Error creating certificate from DER data" << std::endl; +// SWIFT_LOG(warning) << "Error creating certificate from DER data"; } parse(); } void OpenSSLCertificate::incrementReferenceCount() const { #if OPENSSL_VERSION_NUMBER >= 0x10100000L diff --git a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp index a183a75..86b0504 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp @@ -204,13 +204,13 @@ static int certVerifyCallback(X509_STORE_CTX* store_ctx, void* arg) // This callback shouldn't have been set up if the context doesn't // have a verifyCertCallback set, but it doesn't hurt to double check std::function<int (const TLSContext *)> cb = context->getVerifyCertCallback(); if (cb != nullptr) { ret = cb(static_cast<const OpenSSLContext*>(context)); } else { - SWIFT_LOG(debug) << "certVerifyCallback called but context.verifyCertCallback is unset" << std::endl; + SWIFT_LOG(debug) << "certVerifyCallback called but context.verifyCertCallback is unset"; ret = 0; } context->setX509StoreContext(nullptr); return ret; } @@ -247,18 +247,18 @@ static int verifyCallback(int preverifyOk, X509_STORE_CTX* ctx) int err = X509_STORE_CTX_get_error(ctx); int depth = X509_STORE_CTX_get_error_depth(ctx); SSL* ssl = static_cast<SSL*>(X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx())); SSL_CTX* sslctx = ssl ? SSL_get_SSL_CTX(ssl) : nullptr; if (!sslctx) { - SWIFT_LOG(debug) << "verifyCallback: internal error" << std::endl; + SWIFT_LOG(debug) << "verifyCallback: internal error"; return preverifyOk; } if (SSL_CTX_get_verify_mode(sslctx) == SSL_VERIFY_NONE) { - SWIFT_LOG(debug) << "verifyCallback: no verification required" << std::endl; + SWIFT_LOG(debug) << "verifyCallback: no verification required"; // No verification requested return 1; } X509* errCert = X509_STORE_CTX_get_current_cert(ctx); std::string subjectString; @@ -285,16 +285,16 @@ static int verifyCallback(int preverifyOk, X509_STORE_CTX* ctx) if (errCert) { X509_NAME* issuerName = X509_get_issuer_name(errCert); issuerString = X509_NAME_to_text(issuerName); } SWIFT_LOG(debug) << "verifyCallback: verification error " << X509_verify_cert_error_string(err) << " depth: " << - depth << " issuer: " << ((issuerString.length() > 0) ? issuerString : "<unknown>") << std::endl; + depth << " issuer: " << ((issuerString.length() > 0) ? issuerString : "<unknown>"); } else { SWIFT_LOG(debug) << "verifyCallback: SSL depth: " << depth << " Subject: " << - ((subjectString.length() > 0) ? subjectString : "<>") << std::endl; + ((subjectString.length() > 0) ? subjectString : "<>"); } // Always return "OK", as check on verification status // will be performed once TLS handshake has completed, // by calling OpenSSLContext::getVerificationErrorTypeForResult() to // get the value set via X509_STORE_CTX_set_error() above. return 1; @@ -302,37 +302,37 @@ static int verifyCallback(int preverifyOk, X509_STORE_CTX* ctx) bool OpenSSLContext::configure(const TLSOptions &options) { if (options.cipherSuites) { std::string cipherSuites = *(options.cipherSuites); if (SSL_CTX_set_cipher_list(context_.get(), cipherSuites.c_str()) != 1 ) { - SWIFT_LOG(debug) << "Failed to set cipher-suites" << std::endl; + SWIFT_LOG(debug) << "Failed to set cipher-suites"; return false; } } if (options.context) { const auto& contextId = *options.context; if (SSL_CTX_set_session_id_context(context_.get(), reinterpret_cast<const unsigned char *>(contextId.c_str()), contextId.length()) != 1) { - SWIFT_LOG(debug) << "Failed to set context-id" << std::endl; + SWIFT_LOG(debug) << "Failed to set context-id"; return false; } } if (options.sessionCacheTimeout) { int scto = *options.sessionCacheTimeout; if (scto <= 0) { - SWIFT_LOG(debug) << "Invalid value for session-cache-timeout" << std::endl; + SWIFT_LOG(debug) << "Invalid value for session-cache-timeout"; return false; } (void)SSL_CTX_set_timeout(context_.get(), scto); if (SSL_CTX_get_timeout(context_.get()) != scto) { - SWIFT_LOG(debug) << "Failed to set session-cache-timeout" << std::endl; + SWIFT_LOG(debug) << "Failed to set session-cache-timeout"; return false; } } if (options.verifyCertificateCallback) { verifyCertCallback = *options.verifyCertificateCallback; @@ -368,13 +368,13 @@ bool OpenSSLContext::configure(const TLSOptions &options) } } if (options.verifyDepth) { int depth = *options.verifyDepth; if (depth <= 0) { - SWIFT_LOG(debug) << "Invalid value for verify-depth" << std::endl; + SWIFT_LOG(debug) << "Invalid value for verify-depth"; return false; } // Increase depth limit by one, so that verifyCallback() will log it SSL_CTX_set_verify_depth(context_.get(), depth + 1); } @@ -590,13 +590,13 @@ void OpenSSLContext::sendPendingDataToApplication() { onError(std::make_shared<TLSError>(TLSError::UnknownError, openSSLInternalErrorToString())); } } bool OpenSSLContext::setCertificateChain(const std::vector<std::shared_ptr<Certificate>>& certificateChain) { if (certificateChain.size() == 0) { - SWIFT_LOG(debug) << "Trying to load empty certificate chain." << std::endl; + SWIFT_LOG(debug) << "Trying to load empty certificate chain."; return false; } // load endpoint certificate auto openSSLCert = dynamic_cast<OpenSSLCertificate*>(certificateChain[0].get()); if (!openSSLCert) { @@ -613,13 +613,13 @@ bool OpenSSLContext::setCertificateChain(const std::vector<std::shared_ptr<Certi auto openSSLCert = dynamic_cast<OpenSSLCertificate*>(certificate->get()); if (!openSSLCert) { return false; } if (SSL_CTX_add_extra_chain_cert(context_.get(), openSSLCert->getInternalX509().get()) != 1) { - SWIFT_LOG(debug) << "Trying to load empty certificate chain." << std::endl; + SWIFT_LOG(debug) << "Trying to load empty certificate chain."; return false; } // Have to manually increment reference count as SSL_CTX_add_extra_chain_cert does not do so openSSLCert->incrementReferenceCount(); } } diff --git a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp index 12445fd..e332ca8 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp @@ -44,20 +44,20 @@ ByteArray OpenSSLContextFactory::convertDHParametersFromPEMToDER(const std::stri } return dhParametersInDER; } void OpenSSLContextFactory::setCheckCertificateRevocation(bool check) { if (check) { - SWIFT_LOG(warning) << "CRL Checking not supported for OpenSSL" << std::endl; + SWIFT_LOG(warning) << "CRL Checking not supported for OpenSSL"; assert(false); } } void OpenSSLContextFactory::setDisconnectOnCardRemoval(bool check) { if (check) { - SWIFT_LOG(warning) << "Smart cards not supported for OpenSSL" << std::endl; + SWIFT_LOG(warning) << "Smart cards not supported for OpenSSL"; } } } |
Swift