arpadboda commented on a change in pull request #666: MINIFICPP-1070 - Fixed 
handling of PKCS12 certificates
URL: https://github.com/apache/nifi-minifi-cpp/pull/666#discussion_r337779146
 
 

 ##########
 File path: libminifi/src/controllers/SSLContextService.cpp
 ##########
 @@ -80,7 +82,16 @@ bool SSLContextService::configure_ssl_context(SSL_CTX *ctx) 
{
         X509_free(cert);
         return false;
       }
-      if (SSL_CTX_use_PrivateKey(ctx, pkey) != 1) {
+         while (ca != nullptr && sk_X509_num(ca)) {
+                 X509 * cacert = sk_X509_pop(ca);
+                 if (SSL_CTX_add_extra_chain_cert(ctx, cacert) != 1) {
+                         logging::LOG_ERROR(logger_) << "Failed to set 
additional certificate from  " << certificate << ", " << 
getLatestOpenSSLErrorString();
+                         EVP_PKEY_free(pkey);
+                         X509_free(cacert);
+                         return false;
 
 Review comment:
   So we iterate through "ca" and free one of the certs in case of error and 
leave the rest. This definitely feels wrong. 

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