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

Function ResolveTlsProtocolVersion

lib/base/tlsutility.cpp:271–283  ·  view source on GitHub ↗

* Resolves a string describing a TLS protocol version to the value of a TLS*_VERSION macro of OpenSSL. * * Throws an exception if the version is unknown or not supported. * * @param version String of a TLS version, for example "TLSv1.2". * @return The value of the corresponding TLS*_VERSION macro. */

Source from the content-addressed store, hash-verified

269 * @return The value of the corresponding TLS*_VERSION macro.
270 */
271int ResolveTlsProtocolVersion(const std::string& version) {
272 if (version == "TLSv1.2") {
273 return TLS1_2_VERSION;
274 } else if (version == "TLSv1.3") {
275#if OPENSSL_VERSION_NUMBER >= 0x10101000L
276 return TLS1_3_VERSION;
277#else /* OPENSSL_VERSION_NUMBER >= 0x10101000L */
278 throw std::runtime_error("'" + version + "' is only supported with OpenSSL 1.1.1 or newer");
279#endif /* OPENSSL_VERSION_NUMBER >= 0x10101000L */
280 } else {
281 throw std::runtime_error("Unknown TLS protocol version '" + version + "'");
282 }
283}
284
285Shared<boost::asio::ssl::context>::Ptr SetupSslContext(String certPath, String keyPath,
286 String caPath, String crlPath, String cipherList, String protocolmin, DebugInfo di)

Callers 3

Calls

no outgoing calls

Tested by

no test coverage detected