Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7547789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:32:34+00:00 2026-05-30T09:32:34+00:00

I have an asynchronous client and server application that wrap OpenSSL. Once created, they

  • 0

I have an asynchronous client and server application that wrap OpenSSL. Once created, they call SSL_set_connect_state()/SSL_set_accept_state() respectively to initialize their internal state. Up to this point everything is running as it should be. I’m assuming once those aforementioned states are set, hand shaking can begin. I do the following to initialize said hand shaking (snippet):

if (BIO_ctrl_pending(m_pOutBio))
{
    size_t iNumBytes = BIO_ctrl_pending(m_pOutBio);
    if (iNumBytes > 0)
    {
        CAutoPtr<byte> tTempBuf(new byte[iNumBytes]);

        // Transfer bytes from the Write BIO into the temporary buffer
        int iRet = BIO_read(m_pOutBio, tTempBuf, iNumBytes);
    }
}

Here is where it gets interesting. The BIO_ctrl_pending() call fails and when I do a SSL_get_error() on it, it returns with SSL_ERROR_WANT_READ. It then obviously doesn’t not execute my reading code. I added the following line above my code snippet:

SSL_peek(m_pSSLCon, NULL, 0);

Now when I run the code, BIO_ctrl_pending() returns the proper amount (210) and my code can then proceed to read from the BIO and initiate hand shaking.

My question is, is this some sort of bug in OpenSSL where the state doesn’t get set properly?? Or am I missing something??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:32:35+00:00Added an answer on May 30, 2026 at 9:32 am

    Old question but keeps popping up when googling openssl stuff, so for reference:

    Just initiate handshake instead of relying on peek/read doing it internally:
    If it’s not a socket bio the handshake will fail with ssl_error_want_read and then you use ctrl_pending to get the size to read.

    Something like this:

        ret = SSL_do_handshake(client_side);
          if (ret < 0)
            if (SSL_ERROR_WANT_READ !=  SSL_get_error(client_side,ret))
                cout << "ERROR";
    
    
        ret = BIO_ctrl_pending(network_side); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a Client/Server Application that using Asynchronous Socket.My problem is i cant
I currently have a client-server application that involves a Silverlight client and a .NET
I have a legacy C++ application that uses DDS for asynchronous communication/messaging. I need
I'm working on a client/server application in C#, and I need to get Asynchronous
I have implemented a client-server transferring from Windows desktop application to iPhone App. I
I have a client application that scrapes data into a raw table. This client
I have a server and a client application, here's how it's currently implemented: The
I have some simple questions, I have a client-server application and data sent on
My client-server application is mainly based on special purpose http server that communicates with
Is there anyway to have a client side small database that syncs with server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.