make enableSSL behave in a more logic way
This commit is contained in:
parent
81d8902069
commit
90bd8fd914
|
@ -165,22 +165,21 @@ void Socket::enableSSL(bool server)
|
||||||
ssl=SSL_new(ssl_ctx_server);
|
ssl=SSL_new(ssl_ctx_server);
|
||||||
else
|
else
|
||||||
ssl=SSL_new(ssl_ctx_client);
|
ssl=SSL_new(ssl_ctx_client);
|
||||||
if(ssl!=NULL)
|
|
||||||
{
|
if(NULL==ssl)
|
||||||
SSL_set_fd(ssl,fd);
|
|
||||||
ssl_enabled=true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
throw Exception(_("Error creating ssl structure"),__FILE__,__LINE__);
|
throw Exception(_("Error creating ssl structure"),__FILE__,__LINE__);
|
||||||
|
|
||||||
if(server)
|
if(1!=SSL_set_fd(ssl,fd))
|
||||||
retval=SSL_accept(ssl);
|
throw Exception(_("Error setting FD"),__FILE__,__LINE__);
|
||||||
else
|
|
||||||
retval=SSL_connect(ssl);
|
retval=server? SSL_accept(ssl) : SSL_connect(ssl);
|
||||||
|
|
||||||
//SSL_accept and SSL_connect have the same semantics so we handle them together
|
//SSL_accept and SSL_connect have the same semantics so we handle them together
|
||||||
if(1!=retval)
|
if(1!=retval)
|
||||||
throw Exception(_("Error enabling SSL on the socket"),__FILE__,__LINE__);
|
throw Exception(_("Error enabling SSL on the socket"),__FILE__,__LINE__);
|
||||||
|
|
||||||
|
//only set ssl_enabled if we have suceeded with everything
|
||||||
|
ssl_enabled=true;
|
||||||
}
|
}
|
||||||
#endif //HAVE_SSL
|
#endif //HAVE_SSL
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue