26 #include <gnutls/gnutls.h>
27 #define TLS_read(c, buf, size) gnutls_record_recv(c->session, buf, size)
28 #define TLS_write(c, buf, size) gnutls_record_send(c->session, buf, size)
29 #define TLS_shutdown(c) gnutls_bye(c->session, GNUTLS_SHUT_RDWR)
30 #define TLS_free(c) do { \
32 gnutls_deinit(c->session); \
34 gnutls_certificate_free_credentials(c->cred); \
37 #include <openssl/bio.h>
38 #include <openssl/ssl.h>
39 #include <openssl/err.h>
40 #define TLS_read(c, buf, size) SSL_read(c->ssl, buf, size)
41 #define TLS_write(c, buf, size) SSL_write(c->ssl, buf, size)
42 #define TLS_shutdown(c) SSL_shutdown(c->ssl)
43 #define TLS_free(c) do { \
47 SSL_CTX_free(c->ctx); \
61 gnutls_session_t session;
62 gnutls_certificate_credentials_t cred;
73 struct pollfd p = { c->
fd, 0, 0 };
75 if (ret != GNUTLS_E_AGAIN && ret != GNUTLS_E_INTERRUPTED) {
79 if (gnutls_record_get_direction(c->session))
84 ret = SSL_get_error(c->ssl, ret);
85 if (ret == SSL_ERROR_WANT_READ) {
87 }
else if (ret == SSL_ERROR_WANT_WRITE) {
97 int n = poll(&p, 1, 100);
111 char buf[200], host[200];
114 const char *proxy_path;
119 proxy_path = getenv(
"http_proxy");
120 use_proxy = (proxy_path !=
NULL) && !getenv(
"no_proxy") &&
133 char proxy_host[200], proxy_auth[200], dest[200];
136 proxy_host,
sizeof(proxy_host), &proxy_port,
NULL, 0,
139 ff_url_join(buf,
sizeof(buf),
"httpproxy", proxy_auth, proxy_host,
140 proxy_port,
"/%s", dest);
150 gnutls_init(&c->session, GNUTLS_CLIENT);
152 gnutls_server_name_set(c->session, GNUTLS_NAME_DNS, host, strlen(host));
153 gnutls_certificate_allocate_credentials(&c->cred);
154 gnutls_certificate_set_verify_flags(c->cred, 0);
155 gnutls_credentials_set(c->session, GNUTLS_CRD_CERTIFICATE, c->cred);
156 gnutls_transport_set_ptr(c->session, (gnutls_transport_ptr_t)
158 gnutls_priority_set_direct(c->session,
"NORMAL",
NULL);
160 ret = gnutls_handshake(c->session);
167 c->ctx = SSL_CTX_new(TLSv1_client_method());
173 c->ssl = SSL_new(c->ctx);
179 SSL_set_fd(c->ssl, c->
fd);
181 SSL_set_tlsext_host_name(c->ssl, host);
183 ret = SSL_connect(c->ssl);
208 int ret = TLS_read(c, buf, size);
223 int ret = TLS_write(c, buf, size);
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
#define URL_PROTOCOL_FLAG_NETWORK
AVIOInterruptCB interrupt_callback
miscellaneous OS support macros and functions.
static int tls_read(URLContext *h, uint8_t *buf, int size)
static int do_tls_poll(URLContext *h, int ret)
void av_log(void *avcl, int level, const char *fmt,...)
URLProtocol ff_tls_protocol
#define AVIO_FLAG_NONBLOCK
static int tls_open(URLContext *h, const char *uri, int flags)
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
static int tls_close(URLContext *h)
#define AVIO_FLAG_READ_WRITE
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrup a blocking function associated with cb.
Describe the class of an AVClass context structure.
int ffurl_close(URLContext *h)
Close the resource accessed by the URLContext h, and free the memory used by it.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
static int tls_write(URLContext *h, const uint8_t *buf, int size)
unbuffered private I/O API