arpadboda commented on a change in pull request #610: MINIFICPP-814 - Fixed 
ListenHTTP and HTTPClient bugs, created tests f…
URL: https://github.com/apache/nifi-minifi-cpp/pull/610#discussion_r303797486
 
 

 ##########
 File path: extensions/http-curl/client/HTTPClient.cpp
 ##########
 @@ -148,6 +161,52 @@ void HTTPClient::setDisableHostVerification() {
   curl_easy_setopt(http_session_, CURLOPT_SSL_VERIFYHOST, 0L);
 }
 
+bool HTTPClient::setSpecificSSLVersion(SSLVersion specific_version) {
+#if CURL_AT_LEAST_VERSION(7, 54, 0)
+  CURLcode ret = CURLE_UNKNOWN_OPTION;
+  switch (specific_version) {
+    case SSLVersion::SSLv2:
+      ret = curl_easy_setopt(http_session_, CURLOPT_SSLVERSION, 
CURL_SSLVERSION_SSLv2);
+      break;
+    case SSLVersion::SSLv3:
+      ret = curl_easy_setopt(http_session_, CURLOPT_SSLVERSION, 
CURL_SSLVERSION_SSLv3);
+      break;
+    case SSLVersion::TLSv1_0:
+      ret = curl_easy_setopt(http_session_, CURLOPT_SSLVERSION, 
CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_TLSv1_0);
+      break;
+    case SSLVersion::TLSv1_1:
+      ret = curl_easy_setopt(http_session_, CURLOPT_SSLVERSION, 
CURL_SSLVERSION_TLSv1_1 | CURL_SSLVERSION_MAX_TLSv1_1);
+      break;
+    case SSLVersion::TLSv1_2:
+      ret = curl_easy_setopt(http_session_, CURLOPT_SSLVERSION, 
CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_TLSv1_2);
+      break;
+  }
+
+  return ret == CURLE_OK;
+#else
+  return false;
+#endif
+}
+
+bool HTTPClient::setMinimumSSLVersion(SSLVersion minimum_version) {
+  CURLcode ret = CURLE_UNKNOWN_OPTION;
+  switch (minimum_version) {
+    case SSLVersion::SSLv2:
+    case SSLVersion::SSLv3:
+    case SSLVersion::TLSv1_0:
+      ret = curl_easy_setopt(http_session_, CURLOPT_SSLVERSION, 
CURL_SSLVERSION_TLSv1_0);
+      break;
+    case SSLVersion::TLSv1_1:
+      ret = curl_easy_setopt(http_session_, CURLOPT_SSLVERSION, 
CURL_SSLVERSION_TLSv1_1);
+      break;
+    case SSLVersion::TLSv1_2:
+      ret = curl_easy_setopt(http_session_, CURLOPT_SSLVERSION, 
CURL_SSLVERSION_TLSv1_2);
 
 Review comment:
   Just a nitpicking code hygiene comment: 
   In these switch cases just save the depending parameter to a variable and 
only write the function call once. 
   
   This is okay as it is, feel free to leave it in case you disagree with the 
above. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to