bakaid 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_r302967745
 
 

 ##########
 File path: extensions/http-curl/client/HTTPClient.cpp
 ##########
 @@ -346,38 +377,38 @@ bool HTTPClient::matches(const std::string &value, const 
std::string &sregex) {
 }
 
 void HTTPClient::configure_secure_connection(CURL *http_session) {
-#ifdef USE_CURL_NSS
-  setVerbose();
-  logger_->log_debug("Using NSS and certificate file %s", 
ssl_context_service_->getCertificateFile());
-  logger_->log_debug("Using NSS and CA certificate file %s", 
ssl_context_service_->getCACertificate());
-  curl_easy_setopt(http_session, CURLOPT_CAINFO, 0);
-  if 
(utils::StringUtils::endsWithIgnoreCase(ssl_context_service_->getCertificateFile(),"p12"))
 {
-    curl_easy_setopt(http_session, CURLOPT_SSLCERTTYPE, "P12");
-  }
-  else {
-    curl_easy_setopt(http_session, CURLOPT_SSLCERTTYPE, "PEM");
+  logger_->log_debug("Using certificate file \"%s\"", 
ssl_context_service_->getCertificateFile());
+  logger_->log_debug("Using private key file \"%s\"", 
ssl_context_service_->getPrivateKeyFile());
+  logger_->log_debug("Using CA certificate file \"%s\"", 
ssl_context_service_->getCACertificate());
+  if (!ssl_context_service_->getCertificateFile().empty()) {
+    if 
(utils::StringUtils::endsWithIgnoreCase(ssl_context_service_->getCertificateFile(),"p12"))
 {
+      curl_easy_setopt(http_session, CURLOPT_SSLCERTTYPE, "P12");
+    }
+    else {
+      curl_easy_setopt(http_session, CURLOPT_SSLCERTTYPE, "PEM");
+    }
+    curl_easy_setopt(http_session, CURLOPT_SSLCERT, 
ssl_context_service_->getCertificateFile().c_str());
   }
-  curl_easy_setopt(http_session, CURLOPT_SSLCERT, 
ssl_context_service_->getCertificateFile().c_str());
-  if 
(utils::StringUtils::endsWithIgnoreCase(ssl_context_service_->getPrivateKeyFile(),"p12"))
 {
-    curl_easy_setopt(http_session, CURLOPT_SSLKEYTYPE, "P12");
+  if (!ssl_context_service_->getPrivateKeyFile().empty()) {
+    if 
(utils::StringUtils::endsWithIgnoreCase(ssl_context_service_->getPrivateKeyFile(),"p12"))
 {
+      curl_easy_setopt(http_session, CURLOPT_SSLKEYTYPE, "P12");
+    }
+    else {
+      curl_easy_setopt(http_session, CURLOPT_SSLKEYTYPE, "PEM");
+    }
+    curl_easy_setopt(http_session, CURLOPT_SSLKEY, 
ssl_context_service_->getPrivateKeyFile().c_str());
+    curl_easy_setopt(http_session, CURLOPT_KEYPASSWD, 
ssl_context_service_->getPassphrase().c_str());
   }
-  else {
-    curl_easy_setopt(http_session, CURLOPT_SSLKEYTYPE, "PEM");
+  if (!ssl_context_service_->getCACertificate().empty()) {
+    curl_easy_setopt(http_session, CURLOPT_CAINFO, 
ssl_context_service_->getCACertificate().c_str());
+  } else {
+    curl_easy_setopt(http_session, CURLOPT_CAINFO, nullptr);
   }
-  curl_easy_setopt(http_session, CURLOPT_SSLKEY, 
ssl_context_service_->getPrivateKeyFile().c_str());
-  curl_easy_setopt(http_session, CURLOPT_KEYPASSWD, 
ssl_context_service_->getPassphrase().c_str());
-  curl_easy_setopt(http_session, CURLOPT_CAINFO, 
ssl_context_service_->getCACertificate().c_str());
-#else
-  logger_->log_debug("Using OpenSSL and certificate file %s", 
ssl_context_service_->getCertificateFile());
-  curl_easy_setopt(http_session, CURLOPT_SSL_CTX_FUNCTION, 
&configure_ssl_context);
-  curl_easy_setopt(http_session, CURLOPT_SSL_CTX_DATA, 
static_cast<void*>(ssl_context_service_.get()));
-  curl_easy_setopt(http_session, CURLOPT_CAINFO, 0);
-  curl_easy_setopt(http_session, CURLOPT_CAPATH, 0);
-#endif
+  curl_easy_setopt(http_session, CURLOPT_CAPATH, nullptr);
 }
 
 bool HTTPClient::isSecure(const std::string &url) {
-  if (url.find("https") != std::string::npos) {
+  if (url.find("https") == 0U) {
 
 Review comment:
   http://https.totallysafe.ru is not a secure URL.

----------------------------------------------------------------
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