MCPcopy Create free account
hub / github.com/ashkulz/NppFTP / authenticate_key

Method authenticate_key

src/FTPClientWrapperSSH.cpp:568–594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

566}
567
568int FTPClientWrapperSSH::authenticate_key(ssh_session session) {
569 int rc = SSH_AUTH_ERROR;
570
571 char * keyfile = SU::TCharToCP(m_keyFile, CP_ACP);
572 ssh_key privkey = NULL;
573 //in case the passphrase is empty, use NULL instead
574 rc = ssh_pki_import_privkey_file(keyfile, m_passphrase[0] ? m_passphrase : NULL, NULL, NULL, &privkey);
575 SU::FreeChar(keyfile);
576
577 if (rc == SSH_EOF) {
578 OutErr("[SFTP] Private key file not found or permission denied");
579 return SSH_AUTH_ERROR;
580 } else if (rc != SSH_OK) {
581 OutErr("[SFTP] Invalid private key file or incorrect passphrase");
582 return SSH_AUTH_ERROR;
583 }
584
585 rc = ssh_userauth_publickey(session, m_username, privkey);
586
587 ssh_key_free(privkey);
588
589 if (rc == SSH_AUTH_DENIED) {
590 OutErr("[SFTP] Key authentication denied.");
591 }
592
593 return rc;
594}
595
596int FTPClientWrapperSSH::authenticate_password(ssh_session session) {
597 int rc;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected