This code starts a minimal SSL server:
WSAStartup(MakeWord(1,1), WData);
SSL_library_init;
SSL_load_error_strings;
ctx := SSL_CTX_new(SSLv23_server_method);
SSL_CTX_use_certificate_chain_file(ctx, 'cert.pem');
SSL_CTX_use_PrivateKey_file(ctx, 'key.pem', 1);
SSL_CTX_check_private_key(ctx);
bio_ssl := BIO_new_ssl(ctx, 0);
bio_in := BIO_new_accept('443');
BIO_set_accept_bios(bio_in, bio_ssl);
BIO_do_accept(bio_in); // set up the socket
BIO_do_accept(bio_in); // wait for connection
Everything works fine on XP. The code stays in the second BIO_do_accept()
waiting for a connection, and sending an HTTPS request from a browser
causes BIO_do_accept() to return.
On 32-bit Vista Home Premium and 64-bit Windows 7, the second BIO_do_accept() hangs forever, and the browser can’t connect.
Why?
Changing the 32-bit .EXE’s various compatibility modes (Windows XP, Windows NT, etc) has no effect.
I’m using OpenSSL 1.0.0d.
It probably has to do with the double BIO_do_accept() calls.
I took OpenSSL’s S_SERVER.C code, made some changes, and crunched it down to the simpler version below. It works on Vista and Windows 7! It uses a completely different set of BIO calls from the problem code above, non-blocking works, and (unlike S_SERVER.C and most server examples on the Net) Google Chrome POSTs are properly grabbed via timeouts per question 7054471.