Getting sockaddr_in structures from a BIO or SSL struct.

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

Getting sockaddr_in structures from a BIO or SSL struct.

Joe Santapau
Hello All,

Is there a way in the OpenSSL API that allows you to save connection
information from a
BIO_do_accept() on a socket like accept() does ?, specifically a
sockaddr_in structure,
or similar.

If not, I am going to try to populate a BIO or SSL structure using
information from
a standard accept() call and then use the  API to populate a BIO for  
the completetion
of an SSL_accept(), is this safe ? caveats ?

Thanks All,
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Getting sockaddr_in structures from a BIO or SSL struct.

mclellan_dave
Unless you have a specific reason to use BIOs, you can do a regular accept()
and use the socket and sockaddr_in from its return.  Do whatever you want
with the sockaddr_in.  The socket returned by accept() is input to the
SSL_set_fd to associate it with an SSL from SSL_new().  Then later, you
would do an SSL_accept(SSL) to satisfy the expected client SSL_connect().  

In my own application, which added SSL over top of (or should I say
underneath) an existing application protocol, we do a lot of system call
work before we figure out that SSL should be involved. When we figure that
out, it is simple to glue the socket to the SSL and keep going with SSL
taking over from there.  

FWIW.

Dave McLellan - Consulting Software Engineer
EMC Corporation
228 South St.
Hopkinton MA 01748
phone: 508-249-1257
fax 508-497-8030


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Joe Santapau
Sent: Sunday, June 26, 2005 2:11 PM
To: [hidden email]
Subject: Getting sockaddr_in structures from a BIO or SSL struct.

Hello All,

Is there a way in the OpenSSL API that allows you to save connection
information from a
BIO_do_accept() on a socket like accept() does ?, specifically a
sockaddr_in structure,
or similar.

If not, I am going to try to populate a BIO or SSL structure using
information from
a standard accept() call and then use the  API to populate a BIO for  
the completetion
of an SSL_accept(), is this safe ? caveats ?

Thanks All,
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Getting sockaddr_in structures from a BIO or SSL struct.

Thomas J. Hruska
mclellan, dave wrote:
> Unless you have a specific reason to use BIOs, you can do a regular accept()

Typical reason to use BIOs:  Cross-platform portability.  I recommend
using BIOs whenever someone uses the pre-built Win32 OpenSSL
Installation Project binaries and they have difficulties.

Using BIOs in terms of sockets is generally not needed because socket
handles tend to be process global compatable under most OSes whereas
FILE *'s are typically local module compatable only.

Thomas Hruska
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Getting sockaddr_in structures from a BIO or SSL struct.

mclellan_dave
In reply to this post by Joe Santapau
Cross-platform portability: excellent reason.  As long as OpenSSL is
everywhere you need it to be, this is a great reason.

OpenSSL isn't everywhere we needed it, but we had a portable socket library
that is. We buried SSL handling inside of that; using SSL where supported
and customer chooses it, not using it where we can't.

BIOs looked really cool and useful to me.  I'm still looking for an
implementation opportunity.

DaveMclellan

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Thomas J. Hruska
Sent: Sunday, June 26, 2005 10:08 PM
To: [hidden email]
Subject: Re: Getting sockaddr_in structures from a BIO or SSL struct.

mclellan, dave wrote:
> Unless you have a specific reason to use BIOs, you can do a regular
accept()

Typical reason to use BIOs:  Cross-platform portability.  I recommend
using BIOs whenever someone uses the pre-built Win32 OpenSSL
Installation Project binaries and they have difficulties.

Using BIOs in terms of sockets is generally not needed because socket
handles tend to be process global compatable under most OSes whereas
FILE *'s are typically local module compatable only.

Thomas Hruska
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Getting sockaddr_in structures from a BIO or SSL struct.

Joe Santapau
In reply to this post by Thomas J. Hruska
Thanks one and all,

 I had priviously used a socket BIO, but now I think I'll use accept() get
what I need, and then populate it into a SSL *  it might give me
flexability
with the socket itself, timeouts and the like.

Thanks,
Joe S.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Getting sockaddr_in structures from a BIO or SSL struct.

Dr. Stephen Henson
On Tue, Jun 28, 2005, Joe Santapau wrote:

> Thanks one and all,
>
> I had priviously used a socket BIO, but now I think I'll use accept() get
> what I need, and then populate it into a SSL *  it might give me
> flexability
> with the socket itself, timeouts and the like.
>

You can stick to BIOs if you wish. The call BIO_get_fd() will return the
underlying file descriptor for a socket BIO. Once you have the fd you can then
perform whatever operations you want on it.

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]