in reply to IO::Socket::SSL and Net::SSLeay
You don't need to extract the server name yourself. IO::Socket::SSL lets you setup SSL_cert* and SSL_key* as hash and thus can choose the appropriate certificates automagically. There is even example code in the documentation of IO::Socket::SSL for it.