Is there an alternative in OpenSSL to SSL_set_connect_state()/SSL_set_accept_state() for X.509 certificate based authentication?
The problem is that in my application the client and server do not communicate using sockets, and the establishment of direct connection between them is not possible. So what I want from OpenSSL is to ‘expose’ the intermediate SSL context establishment messages which I would then convey to the party at the other end.
Thanks for your help!
The OpenSSL
BIOinterface can be used for this.Use
BIO_new_bio_pair()to create a connected BIO pair. One BIO will be read from and written to by the SSL routines, and the other BIO will be read from and written to by your application (allowing it to pass the data to the other end by whatever method it desires).Use
SSL_set_bio()on a new SSL object to set both the read and write BIO to one of the BIOs in the pair generated.Use
BIO_read()andBIO_write()on the other BIO in the pair to read and write the SSL protocol data.Use
SSL_accept(),SSL_connect(),SSL_read()andSSL_write()as normal on the SSL object.