tls: Add options for verifying the peer certificate

A file containing the trusted CA certificates needs to be
supplied via the ca_file AVOption, unless the TLS library
has got a system default file/database set up.

This doesn't check the hostname of the peer certificate with
openssl, which requires a non-trivial piece of code for
manually matching the desired hostname to the string provided
by the certificate, not provided as a library function.

That is, with openssl, this only validates that the received
certificate is signed with the right CA, but not that it is
the actual server we think we're talking to.

Verification is still disabled by default since we can't count
on a proper CA database existing at all times.

Signed-off-by: Martin Storsjö <martin@martin.st>
http: Pass options through to the nested protocol

When passing a dict to the nested protocol, it will consume
the used options from it, so a separate copy needs to be used
when reopening the connection multiple times.

Signed-off-by: Martin Storsjö <martin@martin.st>
tls: Add support for listen mode

Also add options for specifying a certificate and key, which can
be used both when operating as client and as server.

Partially based on a patch by Peter Ross.

Signed-off-by: Martin Storsjö <martin@martin.st>
rtpdec_qt: Add an accidentally removed allocation return value check

This check was mistakenly removed in 5626f994f.

Signed-off-by: Martin Storsjö <martin@martin.st>
lavf: Allocate arrays with av_realloc if they will be realloced later

Pointers returned from av_malloc can't in general be passed
to av_realloc.

Signed-off-by: Martin Storsjö <martin@martin.st>
Merge commit '8b09d917e7dc7d7f2ace31419f802d4ff518236c'

* commit '8b09d917e7dc7d7f2ace31419f802d4ff518236c':
  tls: Add options for verifying the peer certificate

Conflicts:
	doc/protocols.texi
	libavformat/tls.c
	libavformat/version.h

See: b2460858f64b2070d84dd861d4bbd16acfb9b0e9
See: 973a758f52a4e5fe63bd88806a4b2db034a032de
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit '5c53bf7aaf03748464cbf978bffe7ffdb71112b1'

* commit '5c53bf7aaf03748464cbf978bffe7ffdb71112b1':
  http: Pass options through to the nested protocol

Conflicts:
	libavformat/http.c

See: b6f435fbc87c024f8403fca69e6e6b98bccf93fa
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit '705b748e8d8612385c96428ae36ed0d42a170d93'

* commit '705b748e8d8612385c96428ae36ed0d42a170d93':
  tls: Add support for listen mode

Conflicts:
	doc/protocols.texi
	libavformat/tls.c
	libavformat/version.h

See: 4f4eb380f0f96dbb7cdd2b812fa92b8b47a0f27c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit '1af78b865b66acb8020c54262f12aa41ad47e05c'

* commit '1af78b865b66acb8020c54262f12aa41ad47e05c':
  rtpdec_qt: Add an accidentally removed allocation return value check

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Merge commit '06ebc0bf9a6401733a4ce1310325de19f631819a'

* commit '06ebc0bf9a6401733a4ce1310325de19f631819a':
  lavf: Allocate arrays with av_realloc if they will be realloced later

Merged-by: Michael Niedermayer <michaelni@gmx.at>