Go to the documentation of this file.
24 #include <gnutls/gnutls.h>
25 #include <gnutls/x509.h>
35 #ifndef GNUTLS_VERSION_NUMBER
36 #define GNUTLS_VERSION_NUMBER LIBGNUTLS_VERSION_NUMBER
39 #if HAVE_THREADS && GNUTLS_VERSION_NUMBER <= 0x020b00
41 GCRY_THREAD_OPTION_PTHREAD_IMPL;
48 gnutls_certificate_credentials_t
cred;
58 #if HAVE_THREADS && GNUTLS_VERSION_NUMBER < 0x020b00
59 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0)
60 gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
69 gnutls_global_deinit();
79 case GNUTLS_E_INTERRUPTED:
80 #ifdef GNUTLS_E_PREMATURE_TERMINATION
81 case GNUTLS_E_PREMATURE_TERMINATION:
84 case GNUTLS_E_WARNING_ALERT_RECEIVED:
103 if (
c->need_shutdown)
104 gnutls_bye(
c->session, GNUTLS_SHUT_WR);
106 gnutls_deinit(
c->session);
108 gnutls_certificate_free_credentials(
c->cred);
115 void *buf,
size_t len)
133 const void *buf,
size_t len)
161 gnutls_init(&p->
session,
c->listen ? GNUTLS_SERVER : GNUTLS_CLIENT);
162 if (!
c->listen && !
c->numerichost)
163 gnutls_server_name_set(p->
session, GNUTLS_NAME_DNS,
c->host, strlen(
c->host));
164 gnutls_certificate_allocate_credentials(&p->
cred);
166 ret = gnutls_certificate_set_x509_trust_file(p->
cred,
c->ca_file, GNUTLS_X509_FMT_PEM);
170 #if GNUTLS_VERSION_NUMBER >= 0x030020
172 gnutls_certificate_set_x509_system_trust(p->
cred);
174 gnutls_certificate_set_verify_flags(p->
cred,
c->verify ?
175 GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT : 0);
176 if (
c->cert_file &&
c->key_file) {
177 ret = gnutls_certificate_set_x509_key_file(p->
cred,
178 c->cert_file,
c->key_file,
179 GNUTLS_X509_FMT_PEM);
182 "Unable to set cert/key files %s and %s: %s\n",
183 c->cert_file,
c->key_file, gnutls_strerror(
ret));
187 }
else if (
c->cert_file ||
c->key_file)
189 gnutls_credentials_set(p->
session, GNUTLS_CRD_CERTIFICATE, p->
cred);
192 gnutls_transport_set_ptr(p->
session, p);
193 gnutls_set_default_priority(p->
session);
201 if (gnutls_error_is_fatal(
ret)) {
208 unsigned int status, cert_list_size;
209 gnutls_x509_crt_t cert;
210 const gnutls_datum_t *cert_list;
213 gnutls_strerror(
ret));
217 if (
status & GNUTLS_CERT_INVALID) {
222 if (gnutls_certificate_type_get(p->
session) != GNUTLS_CRT_X509) {
227 gnutls_x509_crt_init(&cert);
228 cert_list = gnutls_certificate_get_peers(p->
session, &cert_list_size);
229 gnutls_x509_crt_import(cert, cert_list, GNUTLS_X509_FMT_DER);
230 ret = gnutls_x509_crt_check_hostname(cert,
c->host);
231 gnutls_x509_crt_deinit(cert);
234 "The certificate's owner does not match hostname %s\n",
c->host);
253 ret = gnutls_record_recv(
c->session, buf,
size);
268 ret = gnutls_record_send(
c->session, buf,
size);
void ff_gnutls_init(void)
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define URL_PROTOCOL_FLAG_NETWORK
static ssize_t gnutls_url_pull(gnutls_transport_ptr_t transport, void *buf, size_t len)
#define AVERROR_EOF
End of file.
static int ffurl_write(URLContext *h, const uint8_t *buf, int size)
Write size bytes from buf to the resource accessed by h.
static int print_tls_error(URLContext *h, int ret)
static const AVClass tls_class
static int tls_write(URLContext *h, const uint8_t *buf, int size)
static int ff_mutex_unlock(AVMutex *mutex)
gnutls_certificate_credentials_t cred
#define TLS_COMMON_OPTIONS(pstruct, options_field)
int ffurl_get_short_seek(void *urlcontext)
Return the current short seek threshold value for this URL.
static AVMutex gnutls_mutex
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **options)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int tls_close(URLContext *h)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
const char * av_default_item_name(void *ptr)
Return the context name.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_MUTEX_INITIALIZER
static int tls_get_file_handle(URLContext *h)
static ssize_t gnutls_url_push(gnutls_transport_ptr_t transport, const void *buf, size_t len)
static int ff_mutex_lock(AVMutex *mutex)
static int tls_get_short_seek(URLContext *h)
const URLProtocol ff_tls_protocol
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static const AVOption options[]
static int tls_read(URLContext *h, uint8_t *buf, int size)
#define AVIO_FLAG_NONBLOCK
Use non-blocking mode.
#define flags(name, subs,...)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
void ff_gnutls_deinit(void)
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
static int ffurl_read(URLContext *h, uint8_t *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf.