I'm in a team building a software that incorporates SSH, with a client-server architecture. I'm writing the SSH server, testing on local machine before the deployment on the remote server computer, using the libssh C API. The server builds and links fine, but on running, an error Could not create BIO occurs on the accept function. Below is my server code
unsigned int port = xxxx;
int log_func = SSH_LOG_PROTOCOL;
int rc;
static const char * dsakey = "rservd_dsa_file_key";
static const char * rsakey = "rservd_rsa_file_key";
ssh_init();
ssh_bind sshbind = ssh_bind_new();
ssh_session session = ssh_new();
const char * hostname = "127.0.0.1";
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDADDR, hostname);
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT, &port);
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, dsakey);
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY, &log_func);
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, rsakey);
if(ssh_bind_listen(sshbind)<0)
{
fprintf(stderr, "failed to listen at port %s\n", ssh_get_error(sshbind));
exit(-1);
}
rc = ssh_bind_accept(sshbind, session);
if(rc == SSH_ERROR)
{
fprintf(stderr, "Error in accepting a connection : %s\n", ssh_get_error(sshbind));
exit(-1);
}
ssh_bind_free(sshbind);
ssh_free(session);
After Googling around, I found out that BIO is something to do with SSL but I'm not very sure about it. The libssh community isn't as large, so examples are very few and not as clear as I would have wished. So what might be the cause of this error and what may I do to fix it? FYI This is libssh 0.5.0