diff options
| author | Tim Costen <tim.costen@isode.com> | 2019-10-29 10:25:18 (GMT) |
|---|---|---|
| committer | Kevin Smith <kevin.smith@isode.com> | 2019-10-29 11:52:59 (GMT) |
| commit | 943f4cd11f35573e1af91be578cd058fac34b670 (patch) | |
| tree | 37c14ab65bf2eb3f965f34f5a3b7207c41d41553 /Swiften/TLS/OpenSSL | |
| parent | be7632881677da5267eb711c1f2823ac82d43d09 (diff) | |
| download | swift-943f4cd11f35573e1af91be578cd058fac34b670.zip swift-943f4cd11f35573e1af91be578cd058fac34b670.tar.bz2 | |
Comment out logging calls
Swift OpenSSLContext and OpenSSLCertificate contain a number
of error, warning and info logging calls which have the effect
of writing to stderr. This patch comments them out for now -
a proper interface with a logging object being passed in etc
will be added at a later date.
JIRA: SWIFT-426
Bug:
Release-notes:
Manual:
Test-information:
Compiles OK.
TLSTest runs OK.
Change-Id: I2bc09ff32277c2b669317fcf9748358b2934db7c
Diffstat (limited to 'Swiften/TLS/OpenSSL')
| -rw-r--r-- | Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp | 2 | ||||
| -rw-r--r-- | Swiften/TLS/OpenSSL/OpenSSLContext.cpp | 32 |
2 files changed, 17 insertions, 17 deletions
diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp index bb51428..16b0b2b 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp @@ -26,19 +26,19 @@ OpenSSLCertificate::OpenSSLCertificate(std::shared_ptr<X509> cert) : cert(cert) OpenSSLCertificate::OpenSSLCertificate(const ByteArray& der) { #if OPENSSL_VERSION_NUMBER <= 0x009070cfL 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" << std::endl; } parse(); } void OpenSSLCertificate::incrementReferenceCount() const { #if OPENSSL_VERSION_NUMBER >= 0x10100000L X509_up_ref(cert.get()); #else CRYPTO_add(&(cert.get()->references), 1, CRYPTO_LOCK_EVP_PKEY); diff --git a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp index b7cf178..7034733 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp @@ -201,19 +201,19 @@ static int certVerifyCallback(X509_STORE_CTX* store_ctx, void* arg) int ret; // 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(warning) << "certVerifyCallback called but context.verifyCertCallback is unset" << std::endl; + //SWIFT_LOG(warning) << "certVerifyCallback called but context.verifyCertCallback is unset" << std::endl; ret = 0; } context->setX509StoreContext(nullptr); return ret; } // Convenience function to generate a text representation // of an X509 Name. This information is only used for logging. @@ -244,24 +244,24 @@ static int verifyCallback(int preverifyOk, X509_STORE_CTX* ctx) // Retrieve the pointer to the SSL of the connection currently treated // and the application specific data stored into the SSL object. 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(error) << "verifyCallback: internal error" << std::endl; + //SWIFT_LOG(error) << "verifyCallback: internal error" << std::endl; return preverifyOk; } if (SSL_CTX_get_verify_mode(sslctx) == SSL_VERIFY_NONE) { - SWIFT_LOG(info) << "verifyCallback: no verification required" << std::endl; + //SWIFT_LOG(info) << "verifyCallback: no verification required" << std::endl; // No verification requested return 1; } X509* errCert = X509_STORE_CTX_get_current_cert(ctx); std::string subjectString; if (errCert) { X509_NAME* subjectName = X509_get_subject_name(errCert); subjectString = X509_NAME_to_text(subjectName); @@ -280,62 +280,62 @@ static int verifyCallback(int preverifyOk, X509_STORE_CTX* ctx) X509_STORE_CTX_set_error(ctx, err); } if (!preverifyOk) { std::string issuerString; if (errCert) { X509_NAME* issuerName = X509_get_issuer_name(errCert); issuerString = X509_NAME_to_text(issuerName); } - SWIFT_LOG(error) << "verifyCallback: verification error " << - X509_verify_cert_error_string(err) << " depth: " << - depth << " issuer: " << ((issuerString.length() > 0) ? issuerString : "<unknown>") << std::endl; - } else { - SWIFT_LOG(info) << "verifyCallback: SSL depth: " << depth << " Subject: " << - ((subjectString.length() > 0) ? subjectString : "<>") << std::endl; +// SWIFT_LOG(error) << "verifyCallback: verification error " << +// X509_verify_cert_error_string(err) << " depth: " << +// depth << " issuer: " << ((issuerString.length() > 0) ? issuerString : "<unknown>") << std::endl; +// } else { +// SWIFT_LOG(info) << "verifyCallback: SSL depth: " << depth << " Subject: " << +// ((subjectString.length() > 0) ? subjectString : "<>") << std::endl; } // 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; } 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(error) << "Failed to set cipher-suites" << std::endl; +// SWIFT_LOG(error) << "Failed to set cipher-suites" << std::endl; 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(error) << "Failed to set context-id" << std::endl; +// SWIFT_LOG(error) << "Failed to set context-id" << std::endl; return false; } } if (options.sessionCacheTimeout) { int scto = *options.sessionCacheTimeout; if (scto <= 0) { - SWIFT_LOG(error) << "Invalid value for session-cache-timeout" << std::endl; +// SWIFT_LOG(error) << "Invalid value for session-cache-timeout" << std::endl; return false; } (void)SSL_CTX_set_timeout(context_.get(), scto); if (SSL_CTX_get_timeout(context_.get()) != scto) { - SWIFT_LOG(error) << "Failed to set session-cache-timeout" << std::endl; +// SWIFT_LOG(error) << "Failed to set session-cache-timeout" << std::endl; return false; } } if (options.verifyCertificateCallback) { verifyCertCallback = *options.verifyCertificateCallback; } else { verifyCertCallback = nullptr; } @@ -365,19 +365,19 @@ bool OpenSSLContext::configure(const TLSOptions &options) // been configured via the TLSOptions if (verifyCertCallback != nullptr) { SSL_CTX_set_cert_verify_callback(context_.get(), certVerifyCallback, this); } } if (options.verifyDepth) { int depth = *options.verifyDepth; if (depth <= 0) { - SWIFT_LOG(error) << "Invalid value for verify-depth" << std::endl; +// SWIFT_LOG(error) << "Invalid value for verify-depth" << std::endl; return false; } // Increase depth limit by one, so that verifyCallback() will log it SSL_CTX_set_verify_depth(context_.get(), depth + 1); } auto updateOptionIfPresent = [this](boost::optional<bool> option, int flag) { if (option) { @@ -587,19 +587,19 @@ void OpenSSLContext::sendPendingDataToApplication() { } if (ret < 0 && SSL_get_error(handle_.get(), ret) != SSL_ERROR_WANT_READ) { state_ = State::Error; 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(warning) << "Trying to load empty certificate chain." << std::endl; +// SWIFT_LOG(warning) << "Trying to load empty certificate chain." << std::endl; return false; } // load endpoint certificate auto openSSLCert = dynamic_cast<OpenSSLCertificate*>(certificateChain[0].get()); if (!openSSLCert) { return false; } @@ -610,19 +610,19 @@ bool OpenSSLContext::setCertificateChain(const std::vector<std::shared_ptr<Certi if (certificateChain.size() > 1) { for (auto certificate = certificateChain.begin() + 1; certificate != certificateChain.end(); ++certificate) { 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(warning) << "Trying to load empty certificate chain." << std::endl; +// SWIFT_LOG(warning) << "Trying to load empty certificate chain." << std::endl; return false; } // Have to manually increment reference count as SSL_CTX_add_extra_chain_cert does not do so openSSLCert->incrementReferenceCount(); } } if (handle_) { // This workaround is needed as OpenSSL has a shortcut to not do anything |
Swift