MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / onEnable

Method onEnable

libminifi/src/controllers/SSLContextService.cpp:443–545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443void SSLContextService::onEnable() {
444 valid_ = true;
445 std::string default_dir;
446
447 if (nullptr != configuration_)
448 configuration_->get(Configure::nifi_default_directory, default_dir);
449
450 logger_->log_trace("onEnable()");
451
452 bool has_certificate_property = getProperty(ClientCertificate.getName(), certificate_);
453 if (has_certificate_property) {
454 std::ifstream cert_file(certificate_);
455 if (!cert_file.good()) {
456 logger_->log_warn("Cannot open certificate file %s", certificate_);
457 std::string test_cert = default_dir + certificate_;
458 std::ifstream cert_file_test(test_cert);
459 if (cert_file_test.good()) {
460 certificate_ = test_cert;
461 logger_->log_info("Using certificate file %s", certificate_);
462 } else {
463 logger_->log_error("Cannot open certificate file %s", test_cert);
464 valid_ = false;
465 }
466 cert_file_test.close();
467 }
468 cert_file.close();
469 } else {
470 logger_->log_debug("Certificate empty");
471 }
472
473 if (has_certificate_property && !isFileTypeP12(certificate_)) {
474 if (getProperty(PrivateKey.getName(), private_key_)) {
475 std::ifstream priv_file(private_key_);
476 if (!priv_file.good()) {
477 logger_->log_warn("Cannot open private key file %s", private_key_);
478 std::string test_priv = default_dir + private_key_;
479 std::ifstream private_file_test(test_priv);
480 if (private_file_test.good()) {
481 private_key_ = test_priv;
482 logger_->log_info("Using private key file %s", private_key_);
483 } else {
484 logger_->log_error("Cannot open private key file %s", test_priv);
485 valid_ = false;
486 }
487 private_file_test.close();
488 }
489 priv_file.close();
490 } else {
491 logger_->log_debug("Private key empty");
492 }
493 }
494
495 if (!getProperty(Passphrase.getName(), passphrase_)) {
496 logger_->log_debug("No pass phrase for %s", certificate_);
497 } else {
498 std::ifstream passphrase_file(passphrase_);
499 if (passphrase_file.good()) {
500 passphrase_file_ = passphrase_;

Callers 5

onScheduleMethod · 0.45
enableMethod · 0.45
initializeMethod · 0.45

Calls 9

log_traceMethod · 0.80
log_warnMethod · 0.80
log_infoMethod · 0.80
log_errorMethod · 0.80
log_debugMethod · 0.80
getMethod · 0.45
getNameMethod · 0.45
closeMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected