[openssl-dev] openssl (lib and application) localhost problems.

dE de.techno at gmail.com
Thu Mar 5 06:48:34 UTC 2015


First I encountered problems here --

https://mta.openssl.org/pipermail/openssl-dev/2015-March/000806.html

Guessing if this's a openssl command related problem, but now I've 
problems in code.

     SSL_library_init();
     SSL_load_error_strings();
     const SSL_METHOD* meth;
     meth = TLSv1_2_method();
     SSL_CTX* ctx = SSL_CTX_new(meth);
     if ( ctx == NULL ) {
         printf ("ERROR: TLS internal error!\n");
     }
     SSL* sslconnection = SSL_new (ctx);
     BIO* bioconnection = BIO_new(BIO_s_socket());

     int hSocket = 0;
     struct sockaddr_in server;
     server.sin_family = AF_INET;
     server.sin_port = htons(80);
     server.sin_addr.s_addr = inet_addr ("104.68.173.123");
     hSocket = socket(AF_INET, SOCK_STREAM, 0);
     if (connect(hSocket, (struct sockaddr*) &server, sizeof(server)) < 0)
         printf ("connection failed\n");

     BIO_set_fd(bioconnection, hSocket, BIO_NOCLOSE);
     SSL_set_bio(sslconnection, bioconnection, bioconnection);

     int result = SSL_connect(sslconnection);
     printf ("error no. is %ld\n", ERR_peek_last_error());

This code does work and prints 'error no. is 336130315', but when it 
connects over localhost, the error is always 0.


More information about the openssl-dev mailing list