Security Basics mailing list archives
a problem about openssl lib:SSL_connect()
From: "berg" <zealberg () 163 com>
Date: Thu, 7 Sep 2006 16:33:19 +0800
Hello, everyone I met a problem while using the function SSL_connect(), it always returns -1, and output some chaotic characters to the console(It seems that memory overflow). And I did not capture the ssl handshake packets. Does anyone knows the reason, and how to use it? Thanks for any advise. My codes as follow: ............ int sd; int ret; SSL *ssl; SSL_CTX *ctx; // initial ssl library SSL_library_init(); SSL_load_error_strings(); // create ssl context ctx = SSL_CTX_new(SSLv23_client_method()); if (ctx == NULL) { return -1; } SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); // create ssl ssl = SSL_new(ctx); if (ssl == NULL) { return -1; } // the function below returns a normal tcp connection socket description sd = create_https_socket(dip, dport); if (sd <= 0) { return -1; } ret = SSL_set_fd(ssl, sd); if (ret == 0) { close(sd); return -1; } RAND_poll(); while (RAND_status() == 0) { unsigned short rand_ret = rand() % 65536; RAND_seed(&rand_ret, sizeof(rand_ret)); } // error occur ret = SSL_connect(ssl); printf("ret=%d\n", ret); // the value of ret is -1 if( ret != 1 ) { close(sd); return -1; } ........... Best Regards Berg
Current thread:
- a problem about openssl lib:SSL_connect() berg (Sep 07)
- Re: a problem about openssl lib:SSL_connect() berg (Sep 08)