Win32 BIO server, no accept

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Win32 BIO server, no accept

Karsten Gorkow

Hello,

I'm pretty new to OpenSSL and need to implement a secure connection. It's a Win32 application that uses a standard socket implementation up to now and runs for some years already.

To implement SSL/TLS I downloaded 1.1 and compiled the DLLs for VS2015. The tests are all "green".

Now I started to integrate OpenSSL into the application. First step for me is to replace the socket implementation with BIO, no security stuff is involved yet.

The app can be configured to act as a TCP server or a client. I was able to get it to work via BIO as a client, but the problem is the server role. I don't get a valid (second) accept call, no client is able to connect. Inside the app this is done via a non-blocking listening socket (return value is always -1 with "WOULDBLOCK" set), but I even copied the sample code from the blog (blocking mode) into the app’s initialization code and the second call to BIO_do_accept never returns:

 

 

             SSL_load_error_strings();

             ERR_load_BIO_strings();

             OpenSSL_add_all_algorithms();

 

             BIO *abio, *cbio, *cbio2;

 

             /* First call to BIO_accept() sets up accept BIO */

             abio = BIO_new_accept("4444");

             if (BIO_do_accept(abio) <= 0) {

                           fprintf(stderr, "Error setting up accept\n");

                           ERR_print_errors_fp(stderr);

                           exit(1);

             }

 

             /* Wait for incoming connection */

             if (BIO_do_accept(abio) <= 0) {

                           fprintf(stderr, "Error accepting connection\n");

                           ERR_print_errors_fp(stderr);

                           exit(1);

             }

             fprintf(stderr, "Connection 1 established\n");

 

             /* Retrieve BIO for connection */

             cbio = BIO_pop(abio);

            

              ...

 

What's the problem here? I'm currently running under Win 8.1.

 

Best regards,

Karsten

 


--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users
Reply | Threaded
Open this post in threaded view
|

Re: Win32 BIO server, no accept

Karsten Gorkow

Riddle solved:

Must call BIO_new_accept(“0.0.0.0:4444”) and it works.

 

Von: openssl-users <[hidden email]> Im Auftrag von Karsten Gorkow
Gesendet: Montag, 12. November 2018 18:26
An: [hidden email]
Betreff: [openssl-users] Win32 BIO server, no accept

 

Hello,

I'm pretty new to OpenSSL and need to implement a secure connection. It's a Win32 application that uses a standard socket implementation up to now and runs for some years already.

To implement SSL/TLS I downloaded 1.1 and compiled the DLLs for VS2015. The tests are all "green".

Now I started to integrate OpenSSL into the application. First step for me is to replace the socket implementation with BIO, no security stuff is involved yet.

The app can be configured to act as a TCP server or a client. I was able to get it to work via BIO as a client, but the problem is the server role. I don't get a valid (second) accept call, no client is able to connect. Inside the app this is done via a non-blocking listening socket (return value is always -1 with "WOULDBLOCK" set), but I even copied the sample code from the blog (blocking mode) into the app’s initialization code and the second call to BIO_do_accept never returns:

 

 

             SSL_load_error_strings();

             ERR_load_BIO_strings();

             OpenSSL_add_all_algorithms();

 

             BIO *abio, *cbio, *cbio2;

 

             /* First call to BIO_accept() sets up accept BIO */

             abio = BIO_new_accept("4444");

             if (BIO_do_accept(abio) <= 0) {

                           fprintf(stderr, "Error setting up accept\n");

                           ERR_print_errors_fp(stderr);

                           exit(1);

             }

 

             /* Wait for incoming connection */

             if (BIO_do_accept(abio) <= 0) {

                           fprintf(stderr, "Error accepting connection\n");

                           ERR_print_errors_fp(stderr);

                           exit(1);

             }

             fprintf(stderr, "Connection 1 established\n");

 

             /* Retrieve BIO for connection */

             cbio = BIO_pop(abio);

            

              ...

 

What's the problem here? I'm currently running under Win 8.1.

 

Best regards,

Karsten

 


--
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users