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

Method setHostKeyFile

extensions/sftp/client/SFTPClient.cpp:176–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176bool SFTPClient::setHostKeyFile(const std::string& host_key_file_path, bool strict_host_checking) {
177 if (ssh_known_hosts_ != nullptr) {
178 return false;
179 }
180 ssh_known_hosts_ = libssh2_knownhost_init(ssh_session_);
181 if (ssh_known_hosts_ == nullptr) {
182 char *err_msg = nullptr;
183 libssh2_session_last_error(ssh_session_, &err_msg, nullptr, 0);
184 logger_->log_error("Failed to init knownhost structure, error: %s", err_msg);
185 return false;
186 }
187 if (libssh2_knownhost_readfile(ssh_known_hosts_, host_key_file_path.c_str(), LIBSSH2_KNOWNHOST_FILE_OPENSSH) <= 0) {
188 char *err_msg = nullptr;
189 libssh2_session_last_error(ssh_session_, &err_msg, nullptr, 0);
190 logger_->log_error("Failed to read host file %s, error: %s", host_key_file_path.c_str(), err_msg);
191 return false;
192 }
193 strict_host_checking_ = strict_host_checking;
194 return true;
195}
196
197void SFTPClient::setPasswordAuthenticationCredentials(const std::string& password) {
198 password_authentication_enabled_ = true;

Callers 1

getOrCreateConnectionMethod · 0.45

Calls 2

log_errorMethod · 0.80
c_strMethod · 0.80

Tested by

no test coverage detected