Commit ee0e274d authored by David Woodhouse's avatar David Woodhouse

Make openconnect_init_ssl() return success/failure code

Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 42fec77c
......@@ -262,13 +262,14 @@ char *openconnect__win32_strerror(DWORD err)
return msgutf8;
}
void openconnect__win32_sock_init()
int openconnect__win32_sock_init()
{
WSADATA data;
if (WSAStartup (MAKEWORD(1, 1), &data) != 0) {
fprintf(stderr, _("ERROR: Cannot initialize sockets\n"));
exit(1);
return -EIO;
}
return 0;
}
int openconnect__win32_inet_pton(int af, const char *src, void *dst)
......
......@@ -2161,12 +2161,17 @@ void openconnect_close_https(struct openconnect_info *vpninfo, int final)
}
}
void openconnect_init_ssl(void)
int openconnect_init_ssl(void)
{
#ifdef _WIN32
openconnect__win32_sock_init();
int ret = openconnect__win32_sock_init();
if (ret)
return ret;
#endif
gnutls_global_init();
if (gnutls_global_init())
return -EIO;
else
return 0;
}
char *get_gnutls_cipher(gnutls_session_t session)
......
......@@ -526,7 +526,7 @@ static inline int set_fd_cloexec(int fd)
#ifdef _WIN32
#define pipe(fds) _pipe(fds, 4096, O_BINARY)
void openconnect__win32_sock_init();
int openconnect__win32_sock_init();
char *openconnect__win32_strerror(DWORD err);
#undef inet_pton
#define inet_pton openconnect__win32_inet_pton
......
......@@ -35,6 +35,7 @@
* API version 4.1:
* - Add openconnect_get_cstp_cipher(), openconnect_get_dtls_cipher(),
* openconnect_set_system_trust().
* - Change openconnect_init_ssl() to return int.
*
* API version 4.0:
* - Change string handling to never transfer ownership of allocations.
......@@ -305,7 +306,7 @@ int openconnect_set_http_proxy(struct openconnect_info *vpninfo,
const char *proxy);
int openconnect_passphrase_from_fsid(struct openconnect_info *vpninfo);
int openconnect_obtain_cookie(struct openconnect_info *vpninfo);
void openconnect_init_ssl(void);
int openconnect_init_ssl(void);
/* These are strictly cosmetic. The strings differ depending on
* whether OpenSSL or GnuTLS is being used. And even depending on the
......
......@@ -1547,15 +1547,18 @@ void openconnect_close_https(struct openconnect_info *vpninfo, int final)
}
}
void openconnect_init_ssl(void)
int openconnect_init_ssl(void)
{
#ifdef _WIN32
openconnect__win32_sock_init();
int ret = openconnect__win32_sock_init();
if (ret)
return ret;
#endif
SSL_library_init();
ERR_clear_error();
SSL_load_error_strings();
OpenSSL_add_all_algorithms();
return 0;
}
char *openconnect_get_cert_details(struct openconnect_info *vpninfo,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment