diff --git a/lib/base/array-script.cpp b/lib/base/array-script.cpp index fa7a52dcb..1c00f1106 100644 --- a/lib/base/array-script.cpp +++ b/lib/base/array-script.cpp @@ -107,22 +107,7 @@ static Value ArrayJoin(const Value& separator) ScriptFrame *vframe = ScriptFrame::GetCurrentFrame(); Array::Ptr self = static_cast(vframe->Self); REQUIRE_NOT_NULL(self); - - Value result; - bool first = true; - - ObjectLock olock(self); - for (const Value& item : self) { - if (first) { - first = false; - } else { - result = result + separator; - } - - result = result + item; - } - - return result; + return self->Join(separator); } static Array::Ptr ArrayReverse() diff --git a/lib/base/array.cpp b/lib/base/array.cpp index d9f360c77..08e06fad2 100644 --- a/lib/base/array.cpp +++ b/lib/base/array.cpp @@ -297,6 +297,26 @@ String Array::ToString() const return msgbuf.str(); } +Value Array::Join(const Value& separator) const +{ + Value result; + bool first = true; + + ObjectLock olock(this); + + for (const Value& item : m_Data) { + if (first) { + first = false; + } else { + result = result + separator; + } + + result = result + item; + } + + return result; +} + Array::Ptr Array::Unique() const { std::set result; diff --git a/lib/base/array.hpp b/lib/base/array.hpp index eaecfdf24..2c9a9dda7 100644 --- a/lib/base/array.hpp +++ b/lib/base/array.hpp @@ -94,6 +94,7 @@ public: void Sort(bool overrideFrozen = false); String ToString() const override; + Value Join(const Value& separator) const; Array::Ptr Unique() const; void Freeze(); diff --git a/lib/base/tlsutility.cpp b/lib/base/tlsutility.cpp index de289667a..023fbe0d7 100644 --- a/lib/base/tlsutility.cpp +++ b/lib/base/tlsutility.cpp @@ -176,6 +176,23 @@ void SetCipherListToSSLContext(const std::shared_ptr& << boost::errinfo_api_function("SSL_CTX_set_cipher_list") << errinfo_openssl_error(ERR_peek_error())); } + +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + //With OpenSSL 1.1.0, there might not be any returned 0. + STACK_OF(SSL_CIPHER) *ciphers; + Array::Ptr cipherNames = new Array(); + + ciphers = SSL_CTX_get_ciphers(context->native_handle()); + for (int i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) { + const SSL_CIPHER *cipher = sk_SSL_CIPHER_value(ciphers, i); + String cipher_name = SSL_CIPHER_get_name(cipher); + + cipherNames->Add(cipher_name); + } + + Log(LogNotice, "TlsUtility") + << "Available TLS cipher list: " << cipherNames->Join(" "); +#endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */ } /**