* 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. */
| 269 | * @return The value of the corresponding TLS*_VERSION macro. |
| 270 | */ |
| 271 | int 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 | |
| 285 | Shared<boost::asio::ssl::context>::Ptr SetupSslContext(String certPath, String keyPath, |
| 286 | String caPath, String crlPath, String cipherList, String protocolmin, DebugInfo di) |
no outgoing calls
no test coverage detected