MCPcopy Create free account
hub / github.com/Icinga/icinga2 / SetCipherListToSSLContext

Function SetCipherListToSSLContext

lib/base/tlsutility.cpp:227–261  ·  view source on GitHub ↗

* Set the cipher list to the specified SSL context. * @param context The ssl context. * @param cipherList The ciper list. **/

Source from the content-addressed store, hash-verified

225 * @param cipherList The ciper list.
226 **/
227void SetCipherListToSSLContext(const Shared<boost::asio::ssl::context>::Ptr& context, const String& cipherList)
228{
229 char errbuf[256];
230
231 if (SSL_CTX_set_cipher_list(context->native_handle(), cipherList.CStr()) == 0) {
232 ERR_error_string_n(ERR_peek_error(), errbuf, sizeof errbuf);
233 Log(LogCritical, "SSL")
234 << "Cipher list '"
235 << cipherList
236 << "' does not specify any usable ciphers: "
237 << ERR_peek_error() << ", \""
238 << errbuf << "\"";
239
240 BOOST_THROW_EXCEPTION(openssl_error()
241 << boost::errinfo_api_function("SSL_CTX_set_cipher_list")
242 << errinfo_openssl_error(ERR_peek_error()));
243 }
244
245#if OPENSSL_VERSION_NUMBER >= 0x10100000L
246 //With OpenSSL 1.1.0, there might not be any returned 0.
247 STACK_OF(SSL_CIPHER) *ciphers;
248 Array::Ptr cipherNames = new Array();
249
250 ciphers = SSL_CTX_get_ciphers(context->native_handle());
251 for (int i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) {
252 const SSL_CIPHER *cipher = sk_SSL_CIPHER_value(ciphers, i);
253 String cipher_name = SSL_CIPHER_get_name(cipher);
254
255 cipherNames->Add(cipher_name);
256 }
257
258 Log(LogNotice, "TlsUtility")
259 << "Available TLS cipher list: " << cipherNames->Join(" ");
260#endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */
261}
262
263/**
264 * Resolves a string describing a TLS protocol version to the value of a TLS*_VERSION macro of OpenSSL.

Callers 1

SetupSslContextFunction · 0.85

Calls 5

LogClass · 0.85
openssl_errorClass · 0.85
CStrMethod · 0.80
AddMethod · 0.45
JoinMethod · 0.45

Tested by

no test coverage detected