Wrapped everything OpenSSL related in a SSL_USE_OPENSSL check macro.

This commit is contained in:
Jan Vidar Krey
2012-10-02 23:59:11 +02:00
parent 69603ff70f
commit f20c42d05f
11 changed files with 96 additions and 20 deletions

View File

@@ -731,6 +731,7 @@ static int load_ssl_certificates(struct hub_info* hub, struct hub_config* config
{
if (config->tls_enable)
{
#ifdef SSL_USE_OPENSSL
hub->ssl_method = (SSL_METHOD*) SSLv23_method(); /* TLSv1_method() */
hub->ssl_ctx = SSL_CTX_new(hub->ssl_method);
@@ -754,18 +755,21 @@ static int load_ssl_certificates(struct hub_info* hub, struct hub_config* config
return 0;
}
LOG_INFO("Enabling TLS, using certificate: %s, private key: %s", config->tls_certificate, config->tls_private_key);
#endif /* SSL_USE_OPENSSL */
}
return 1;
}
static void unload_ssl_certificates(struct hub_info* hub)
{
#ifdef SSL_USE_OPENSSL
if (hub->ssl_ctx)
{
SSL_CTX_free(hub->ssl_ctx);
}
#endif /* SSL_USE_OPENSSL */
}
#endif
#endif /* SSL_SUPPORT */
struct hub_info* hub_start_service(struct hub_config* config)
{

View File

@@ -116,8 +116,10 @@ struct hub_info
struct uhub_plugins* plugins; /* Plug-ins loaded for this hub instance. */
#ifdef SSL_SUPPORT
#ifdef SSL_USE_OPENSSL
SSL_METHOD* ssl_method;
SSL_CTX* ssl_ctx;
#endif // SSL_USE_OPENSSL
#endif /* SSL_SUPPORT */
};

View File

@@ -85,7 +85,9 @@ static void probe_net_event(struct net_connection* con, int events, void *arg)
{
probe->connection = 0;
}
#ifdef SSL_USE_OPENSSL
net_con_ssl_handshake(con, net_con_ssl_mode_server, probe->hub->ssl_ctx);
#endif /* SSL_USE_OPENSSL */
}
else
{