Ich habe dieses einfache Programm:OpenSSL segfault
int main()
{
/* INITIALIZING OPENSSL */
SSL_library_init();
SSL_load_error_strings();
ERR_load_BIO_strings();
OpenSSL_add_all_algorithms();
BIO *bio;
connectServerSSL(bio);
login(bio);
}
Und diese Funktionen:
void connectServerSSL (BIO *bio)
{
SSL_CTX * ctx = SSL_CTX_new(SSLv23_client_method());
SSL * ssl;
if(! SSL_CTX_load_verify_locations(ctx, NULL, "/etc/ssl/certs"))
{
callError(ERR_LOADCERT);
}
bio = BIO_new_ssl_connect(ctx);
BIO_get_ssl(bio, &ssl);
SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
BIO_set_conn_hostname(bio, hostnamePort);
if(BIO_do_connect(bio) <= 0)
{
callError(ERR_CONNECTION);
}
if(SSL_get_verify_result(ssl) != X509_V_OK)
{
callError(ERR_VALIDCERT);
}
}
Als ich diese verwenden:
BIO_write (bio, request.c_str(), request.size())
In f Verbindung conneServerSSL funktioniert es OK.
Aber wenn ich es in einer anderen Funktion verwenden möchten:
void login (BIO *bio)
{
BIO_write(bio, request.c_str(), request.size());
}
I Segmentation fault bekommen (core dumped).
Sie sind nicht Ihre 'bio' von' connectServerSSL' zurückzukehren. – tkausl
Wie kann ich das bitte machen? –