summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Mons <edwin.mons@isode.com>2019-11-19 13:36:05 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2019-11-19 13:58:45 (GMT)
commit261ba8d8595ed8cb90f9c4feb1d6ef642942bcba (patch)
treec7e60d473509db8c4dbff5aa83fbde963d8dd75e /Swiften/TLS/OpenSSL
parent697ae6ae84512a744958b24118197ec7bfdbc1f0 (diff)
downloadswift-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.cpp4
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLContext.cpp24
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLContextFactory.cpp4
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,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2016 Isode Limited. 2 * Copyright (c) 2010-2019 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
@@ -32,7 +32,7 @@ OpenSSLCertificate::OpenSSLCertificate(const ByteArray& der) {
32#endif 32#endif
33 cert = std::shared_ptr<X509>(d2i_X509(nullptr, &p, der.size()), X509_free); 33 cert = std::shared_ptr<X509>(d2i_X509(nullptr, &p, der.size()), X509_free);
34 if (!cert) { 34 if (!cert) {
35// SWIFT_LOG(warning) << "Error creating certificate from DER data" << std::endl; 35// SWIFT_LOG(warning) << "Error creating certificate from DER data";
36 } 36 }
37 parse(); 37 parse();
38} 38}
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
@@ -207,7 +207,7 @@ static int certVerifyCallback(X509_STORE_CTX* store_ctx, void* arg)
207 if (cb != nullptr) { 207 if (cb != nullptr) {
208 ret = cb(static_cast<const OpenSSLContext*>(context)); 208 ret = cb(static_cast<const OpenSSLContext*>(context));
209 } else { 209 } else {
210 SWIFT_LOG(debug) << "certVerifyCallback called but context.verifyCertCallback is unset" << std::endl; 210 SWIFT_LOG(debug) << "certVerifyCallback called but context.verifyCertCallback is unset";
211 ret = 0; 211 ret = 0;
212 } 212 }
213 213
@@ -250,12 +250,12 @@ static int verifyCallback(int preverifyOk, X509_STORE_CTX* ctx)
250 SSL* ssl = static_cast<SSL*>(X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx())); 250 SSL* ssl = static_cast<SSL*>(X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx()));
251 SSL_CTX* sslctx = ssl ? SSL_get_SSL_CTX(ssl) : nullptr; 251 SSL_CTX* sslctx = ssl ? SSL_get_SSL_CTX(ssl) : nullptr;
252 if (!sslctx) { 252 if (!sslctx) {
253 SWIFT_LOG(debug) << "verifyCallback: internal error" << std::endl; 253 SWIFT_LOG(debug) << "verifyCallback: internal error";
254 return preverifyOk; 254 return preverifyOk;
255 } 255 }
256 256
257 if (SSL_CTX_get_verify_mode(sslctx) == SSL_VERIFY_NONE) { 257 if (SSL_CTX_get_verify_mode(sslctx) == SSL_VERIFY_NONE) {
258 SWIFT_LOG(debug) << "verifyCallback: no verification required" << std::endl; 258 SWIFT_LOG(debug) << "verifyCallback: no verification required";
259 // No verification requested 259 // No verification requested
260 return 1; 260 return 1;
261 } 261 }
@@ -288,10 +288,10 @@ static int verifyCallback(int preverifyOk, X509_STORE_CTX* ctx)
288 } 288 }
289 SWIFT_LOG(debug) << "verifyCallback: verification error " << 289 SWIFT_LOG(debug) << "verifyCallback: verification error " <<
290 X509_verify_cert_error_string(err) << " depth: " << 290 X509_verify_cert_error_string(err) << " depth: " <<
291 depth << " issuer: " << ((issuerString.length() > 0) ? issuerString : "<unknown>") << std::endl; 291 depth << " issuer: " << ((issuerString.length() > 0) ? issuerString : "<unknown>");
292 } else { 292 } else {
293 SWIFT_LOG(debug) << "verifyCallback: SSL depth: " << depth << " Subject: " << 293 SWIFT_LOG(debug) << "verifyCallback: SSL depth: " << depth << " Subject: " <<
294 ((subjectString.length() > 0) ? subjectString : "<>") << std::endl; 294 ((subjectString.length() > 0) ? subjectString : "<>");
295 } 295 }
296 // Always return "OK", as check on verification status 296 // Always return "OK", as check on verification status
297 // will be performed once TLS handshake has completed, 297 // will be performed once TLS handshake has completed,
@@ -305,7 +305,7 @@ bool OpenSSLContext::configure(const TLSOptions &options)
305 if (options.cipherSuites) { 305 if (options.cipherSuites) {
306 std::string cipherSuites = *(options.cipherSuites); 306 std::string cipherSuites = *(options.cipherSuites);
307 if (SSL_CTX_set_cipher_list(context_.get(), cipherSuites.c_str()) != 1 ) { 307 if (SSL_CTX_set_cipher_list(context_.get(), cipherSuites.c_str()) != 1 ) {
308 SWIFT_LOG(debug) << "Failed to set cipher-suites" << std::endl; 308 SWIFT_LOG(debug) << "Failed to set cipher-suites";
309 return false; 309 return false;
310 } 310 }
311 } 311 }
@@ -316,7 +316,7 @@ bool OpenSSLContext::configure(const TLSOptions &options)
316 if (SSL_CTX_set_session_id_context(context_.get(), 316 if (SSL_CTX_set_session_id_context(context_.get(),
317 reinterpret_cast<const unsigned char *>(contextId.c_str()), 317 reinterpret_cast<const unsigned char *>(contextId.c_str()),
318 contextId.length()) != 1) { 318 contextId.length()) != 1) {
319 SWIFT_LOG(debug) << "Failed to set context-id" << std::endl; 319 SWIFT_LOG(debug) << "Failed to set context-id";
320 return false; 320 return false;
321 } 321 }
322 } 322 }
@@ -324,12 +324,12 @@ bool OpenSSLContext::configure(const TLSOptions &options)
324 if (options.sessionCacheTimeout) { 324 if (options.sessionCacheTimeout) {
325 int scto = *options.sessionCacheTimeout; 325 int scto = *options.sessionCacheTimeout;
326 if (scto <= 0) { 326 if (scto <= 0) {
327 SWIFT_LOG(debug) << "Invalid value for session-cache-timeout" << std::endl; 327 SWIFT_LOG(debug) << "Invalid value for session-cache-timeout";
328 return false; 328 return false;
329 } 329 }
330 (void)SSL_CTX_set_timeout(context_.get(), scto); 330 (void)SSL_CTX_set_timeout(context_.get(), scto);
331 if (SSL_CTX_get_timeout(context_.get()) != scto) { 331 if (SSL_CTX_get_timeout(context_.get()) != scto) {
332 SWIFT_LOG(debug) << "Failed to set session-cache-timeout" << std::endl; 332 SWIFT_LOG(debug) << "Failed to set session-cache-timeout";
333 return false; 333 return false;
334 } 334 }
335 } 335 }
@@ -371,7 +371,7 @@ bool OpenSSLContext::configure(const TLSOptions &options)
371 if (options.verifyDepth) { 371 if (options.verifyDepth) {
372 int depth = *options.verifyDepth; 372 int depth = *options.verifyDepth;
373 if (depth <= 0) { 373 if (depth <= 0) {
374 SWIFT_LOG(debug) << "Invalid value for verify-depth" << std::endl; 374 SWIFT_LOG(debug) << "Invalid value for verify-depth";
375 return false; 375 return false;
376 } 376 }
377 377
@@ -593,7 +593,7 @@ void OpenSSLContext::sendPendingDataToApplication() {
593 593
594bool OpenSSLContext::setCertificateChain(const std::vector<std::shared_ptr<Certificate>>& certificateChain) { 594bool OpenSSLContext::setCertificateChain(const std::vector<std::shared_ptr<Certificate>>& certificateChain) {
595 if (certificateChain.size() == 0) { 595 if (certificateChain.size() == 0) {
596 SWIFT_LOG(debug) << "Trying to load empty certificate chain." << std::endl; 596 SWIFT_LOG(debug) << "Trying to load empty certificate chain.";
597 return false; 597 return false;
598 } 598 }
599 599
@@ -616,7 +616,7 @@ bool OpenSSLContext::setCertificateChain(const std::vector<std::shared_ptr<Certi
616 } 616 }
617 617
618 if (SSL_CTX_add_extra_chain_cert(context_.get(), openSSLCert->getInternalX509().get()) != 1) { 618 if (SSL_CTX_add_extra_chain_cert(context_.get(), openSSLCert->getInternalX509().get()) != 1) {
619 SWIFT_LOG(debug) << "Trying to load empty certificate chain." << std::endl; 619 SWIFT_LOG(debug) << "Trying to load empty certificate chain.";
620 return false; 620 return false;
621 } 621 }
622 // Have to manually increment reference count as SSL_CTX_add_extra_chain_cert does not do so 622 // Have to manually increment reference count as SSL_CTX_add_extra_chain_cert does not do so
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
@@ -47,14 +47,14 @@ ByteArray OpenSSLContextFactory::convertDHParametersFromPEMToDER(const std::stri
47 47
48void OpenSSLContextFactory::setCheckCertificateRevocation(bool check) { 48void OpenSSLContextFactory::setCheckCertificateRevocation(bool check) {
49 if (check) { 49 if (check) {
50 SWIFT_LOG(warning) << "CRL Checking not supported for OpenSSL" << std::endl; 50 SWIFT_LOG(warning) << "CRL Checking not supported for OpenSSL";
51 assert(false); 51 assert(false);
52 } 52 }
53} 53}
54 54
55void OpenSSLContextFactory::setDisconnectOnCardRemoval(bool check) { 55void OpenSSLContextFactory::setDisconnectOnCardRemoval(bool check) {
56 if (check) { 56 if (check) {
57 SWIFT_LOG(warning) << "Smart cards not supported for OpenSSL" << std::endl; 57 SWIFT_LOG(warning) << "Smart cards not supported for OpenSSL";
58 } 58 }
59} 59}
60 60