sslconn.h
Go to the documentation of this file.
/* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef _PURPLE_SSLCONN_H_
#define _PURPLE_SSLCONN_H_
typedef enum
{
PURPLE_SSL_HANDSHAKE_FAILED = 1,
PURPLE_SSL_CONNECT_FAILED = 2,
PURPLE_SSL_CERTIFICATE_INVALID = 3
} PurpleSslErrorType;
#include "certificate.h"
#include "proxy.h"
#define PURPLE_SSL_DEFAULT_PORT 443
typedef struct _PurpleSslConnection PurpleSslConnection;
typedef void (*PurpleSslInputFunction)(gpointer, PurpleSslConnection *,
PurpleInputCondition);
typedef void (*PurpleSslErrorFunction)(PurpleSslConnection *, PurpleSslErrorType,
gpointer);
struct _PurpleSslConnection
{
char *host;
int port;
void *connect_cb_data;
PurpleSslInputFunction connect_cb;
PurpleSslErrorFunction error_cb;
void *recv_cb_data;
PurpleSslInputFunction recv_cb;
int fd;
guint inpa;
PurpleProxyConnectData *connect_data;
void *private_data;
PurpleCertificateVerifier *verifier;
};
typedef struct
{
gboolean (*init)(void);
void (*uninit)(void);
void (*connectfunc)(PurpleSslConnection *gsc);
void (*close)(PurpleSslConnection *gsc);
size_t (*read)(PurpleSslConnection *gsc, void *data, size_t len);
size_t (*write)(PurpleSslConnection *gsc, const void *data, size_t len);
GList * (* get_peer_certificates)(PurpleSslConnection * gsc);
void (*_purple_reserved2)(void);
void (*_purple_reserved3)(void);
void (*_purple_reserved4)(void);
} PurpleSslOps;
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************/
/**************************************************************************/
gboolean purple_ssl_is_supported(void);
const gchar * purple_ssl_strerror(PurpleSslErrorType error);
PurpleSslConnection *purple_ssl_connect(PurpleAccount *account, const char *host,
int port, PurpleSslInputFunction func,
PurpleSslErrorFunction error_func,
void *data);
PurpleSslConnection *purple_ssl_connect_with_ssl_cn(PurpleAccount *account, const char *host,
int port, PurpleSslInputFunction func,
PurpleSslErrorFunction error_func,
const char *ssl_host,
void *data);
#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_SSLCONN_C_)
PurpleSslConnection *purple_ssl_connect_fd(PurpleAccount *account, int fd,
PurpleSslInputFunction func,
PurpleSslErrorFunction error_func,
void *data);
#endif
PurpleSslConnection *purple_ssl_connect_with_host_fd(PurpleAccount *account, int fd,
PurpleSslInputFunction func,
PurpleSslErrorFunction error_func,
const char *host,
void *data);
void purple_ssl_input_add(PurpleSslConnection *gsc, PurpleSslInputFunction func,
void *data);
void purple_ssl_close(PurpleSslConnection *gsc);
size_t purple_ssl_read(PurpleSslConnection *gsc, void *buffer, size_t len);
size_t purple_ssl_write(PurpleSslConnection *gsc, const void *buffer, size_t len);
GList * purple_ssl_get_peer_certificates(PurpleSslConnection *gsc);
/**************************************************************************/
/**************************************************************************/
void purple_ssl_set_ops(PurpleSslOps *ops);
PurpleSslOps *purple_ssl_get_ops(void);
void purple_ssl_init(void);
void purple_ssl_uninit(void);
#ifdef __cplusplus
}
#endif
#endif /* _PURPLE_SSLCONN_H_ */
purple_ssl_get_ops
PurpleSslOps * purple_ssl_get_ops(void)
Returns the current SSL operations structure.
_PurpleCertificateVerifier
A set of operations used to provide logic for verifying a Certificate&#39;s authenticity.
Definition: certificate.h:362
_PurpleSslConnection::verifier
PurpleCertificateVerifier * verifier
Verifier to use in authenticating the peer.
Definition: sslconn.h:79
purple_ssl_is_supported
gboolean purple_ssl_is_supported(void)
Returns whether or not SSL is currently supported.
_PurpleSslConnection::connect_cb_data
void * connect_cb_data
Data to pass to PurpleSslConnection::connect_cb()
Definition: sslconn.h:57
purple_ssl_connect
PurpleSslConnection * purple_ssl_connect(PurpleAccount *account, const char *host, int port, PurpleSslInputFunction func, PurpleSslErrorFunction error_func, void *data)
Makes a SSL connection to the specified host and port.
_PurpleSslConnection::connect_cb
PurpleSslInputFunction connect_cb
Callback triggered once the SSL handshake is complete.
Definition: sslconn.h:59
certificate.h
Public-Key Certificate API.
purple_ssl_write
size_t purple_ssl_write(PurpleSslConnection *gsc, const void *buffer, size_t len)
Writes data to an SSL connection.
_PurpleAccount
Structure representing an account.
Definition: account.h:169
_PurpleSslConnection::error_cb
PurpleSslErrorFunction error_cb
Callback triggered if there is an error during connection.
Definition: sslconn.h:61
purple_ssl_get_peer_certificates
GList * purple_ssl_get_peer_certificates(PurpleSslConnection *gsc)
Obtains the peer&#39;s presented certificates.
purple_ssl_close
void purple_ssl_close(PurpleSslConnection *gsc)
Closes a SSL connection.
_PurpleSslConnection::port
int port
Port to connect to.
Definition: sslconn.h:55
purple_ssl_init
void purple_ssl_init(void)
Initializes the SSL subsystem.
purple_ssl_connect_with_host_fd
PurpleSslConnection * purple_ssl_connect_with_host_fd(PurpleAccount *account, int fd, PurpleSslInputFunction func, PurpleSslErrorFunction error_func, const char *host, void *data)
Makes a SSL connection using an already open file descriptor.
purple_ssl_uninit
void purple_ssl_uninit(void)
Uninitializes the SSL subsystem.
purple_ssl_connect_with_ssl_cn
PurpleSslConnection * purple_ssl_connect_with_ssl_cn(PurpleAccount *account, const char *host, int port, PurpleSslInputFunction func, PurpleSslErrorFunction error_func, const char *ssl_host, void *data)
Makes a SSL connection to the specified host and port, using the separate name to verify with the cer...
_PurpleSslConnection::fd
int fd
File descriptor used to refer to the socket.
Definition: sslconn.h:68
_PurpleSslConnection::private_data
void * private_data
Internal connection data managed by the SSL backend (GnuTLS/LibNSS/whatever)
Definition: sslconn.h:76
PurpleInputCondition
PurpleInputCondition
An input condition.
Definition: eventloop.h:38
_PurpleSslConnection::recv_cb
PurpleSslInputFunction recv_cb
User-defined callback executed when the SSL connection receives data.
Definition: sslconn.h:65
purple_ssl_input_add
void purple_ssl_input_add(PurpleSslConnection *gsc, PurpleSslInputFunction func, void *data)
Adds an input watcher for the specified SSL connection.
PurpleSslErrorType
PurpleSslErrorType
Possible SSL errors.
Definition: sslconn.h:30
_PurpleSslConnection::inpa
guint inpa
Glib event source ID; used to refer to the received data callback in the glib eventloop.
Definition: sslconn.h:71
_PurpleSslConnection
Definition: sslconn.h:50
proxy.h
Proxy API.
purple_ssl_set_ops
void purple_ssl_set_ops(PurpleSslOps *ops)
Sets the current SSL operations structure.
_PurpleSslConnection::host
char * host
Hostname to which the SSL connection will be made.
Definition: sslconn.h:53
purple_ssl_read
size_t purple_ssl_read(PurpleSslConnection *gsc, void *buffer, size_t len)
Reads data from an SSL connection.
purple_ssl_strerror
const gchar * purple_ssl_strerror(PurpleSslErrorType error)
Returns a human-readable string for an SSL error.
_PurpleSslConnection::connect_data
PurpleProxyConnectData * connect_data
Data related to the underlying TCP connection.
Definition: sslconn.h:73
PurpleSslOps
SSL implementation operations structure.
Definition: sslconn.h:88
purple_ssl_connect_fd
PurpleSslConnection * purple_ssl_connect_fd(PurpleAccount *account, int fd, PurpleSslInputFunction func, PurpleSslErrorFunction error_func, void *data)
Makes a SSL connection using an already open file descriptor.
_PurpleSslConnection::recv_cb_data
void * recv_cb_data
Data passed to PurpleSslConnection::recv_cb()
Definition: sslconn.h:63