proxy: Support HTTPS proxy and SOCKS+HTTP(s)

* HTTPS proxies:

An HTTPS proxy receives all transactions over an SSL/TLS connection.
Once a secure connection with the proxy is established, the user agent
uses the proxy as usual, including sending CONNECT requests to instruct
the proxy to establish a [usually secure] TCP tunnel with an origin
server. HTTPS proxies protect nearly all aspects of user-proxy
communications as opposed to HTTP proxies that receive all requests
(including CONNECT requests) in vulnerable clear text.

With HTTPS proxies, it is possible to have two concurrent _nested_
SSL/TLS sessions: the "outer" one between the user agent and the proxy
and the "inner" one between the user agent and the origin server
(through the proxy). This change adds supports for such nested sessions
as well.

A secure connection with a proxy requires its own set of the usual SSL
options (their actual descriptions differ and need polishing, see TODO):

  --proxy-cacert FILE        CA certificate to verify peer against
  --proxy-capath DIR         CA directory to verify peer against
  --proxy-cert CERT[:PASSWD] Client certificate file and password
  --proxy-cert-type TYPE     Certificate file type (DER/PEM/ENG)
  --proxy-ciphers LIST       SSL ciphers to use
  --proxy-crlfile FILE       Get a CRL list in PEM format from the file
  --proxy-insecure           Allow connections to proxies with bad certs
  --proxy-key KEY            Private key file name
  --proxy-key-type TYPE      Private key file type (DER/PEM/ENG)
  --proxy-pass PASS          Pass phrase for the private key
  --proxy-ssl-allow-beast    Allow security flaw to improve interop
  --proxy-sslv2              Use SSLv2
  --proxy-sslv3              Use SSLv3
  --proxy-tlsv1              Use TLSv1
  --proxy-tlsuser USER       TLS username
  --proxy-tlspassword STRING TLS password
  --proxy-tlsauthtype STRING TLS authentication type (default SRP)

All --proxy-foo options are independent from their --foo counterparts,
except --proxy-crlfile which defaults to --crlfile and --proxy-capath
which defaults to --capath.

Curl now also supports %{proxy_ssl_verify_result} --write-out variable,
similar to the existing %{ssl_verify_result} variable.

Supported backends: OpenSSL, GnuTLS, and NSS.

* A SOCKS proxy + HTTP/HTTPS proxy combination:

If both --socks* and --proxy options are given, Curl first connects to
the SOCKS proxy and then connects (through SOCKS) to the HTTP or HTTPS
proxy.

TODO: Update documentation for the new APIs and --proxy-* options.
Look for "Added in 7.XXX" marks.
This commit is contained in:
Alex Rousskov 2016-11-16 10:49:15 -07:00 committed by Daniel Stenberg
parent 8034d8fc62
commit cb4e2be7c6
76 changed files with 3413 additions and 962 deletions

View file

@ -94,7 +94,19 @@ options:
CURLOPT_PROXYPASSWORD
CURLOPT_PROXYUSERNAME
CURLOPT_PROXYUSERPWD
CURLOPT_PROXY_CAINFO
CURLOPT_PROXY_CAPATH
CURLOPT_PROXY_CRLFILE
CURLOPT_PROXY_KEYPASSWD
CURLOPT_PROXY_SERVICE_NAME
CURLOPT_PROXY_SSLCERT
CURLOPT_PROXY_SSLCERTTYPE
CURLOPT_PROXY_SSL_CIPHER_LIST
CURLOPT_PROXY_SSLKEY
CURLOPT_PROXY_SSLKEYTYPE
CURLOPT_PROXY_TLSAUTH_PASSWORD
CURLOPT_PROXY_TLSAUTH_TYPE
CURLOPT_PROXY_TLSAUTH_USERNAME
CURLOPT_RANDOM_FILE
CURLOPT_RANGE
CURLOPT_REFERER
@ -103,6 +115,7 @@ options:
CURLOPT_RTSP_TRANSPORT
CURLOPT_SERVICE_NAME
CURLOPT_SOCKS5_GSSAPI_SERVICE
CURLOPT_SOCKS_PROXY
CURLOPT_SSH_HOST_PUBLIC_KEY_MD5
CURLOPT_SSH_KNOWNHOSTS
CURLOPT_SSH_PRIVATE_KEYFILE

View file

@ -1165,7 +1165,19 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...)
case CURLOPT_PROXYPASSWORD:
case CURLOPT_PROXYUSERNAME:
case CURLOPT_PROXYUSERPWD:
case CURLOPT_PROXY_CAINFO:
case CURLOPT_PROXY_CAPATH:
case CURLOPT_PROXY_CRLFILE:
case CURLOPT_PROXY_KEYPASSWD:
case CURLOPT_PROXY_SERVICE_NAME:
case CURLOPT_PROXY_SSLCERT:
case CURLOPT_PROXY_SSLCERTTYPE:
case CURLOPT_PROXY_SSL_CIPHER_LIST:
case CURLOPT_PROXY_SSLKEY:
case CURLOPT_PROXY_SSLKEYTYPE:
case CURLOPT_PROXY_TLSAUTH_PASSWORD:
case CURLOPT_PROXY_TLSAUTH_TYPE:
case CURLOPT_PROXY_TLSAUTH_USERNAME:
case CURLOPT_RANDOM_FILE:
case CURLOPT_RANGE:
case CURLOPT_REFERER:
@ -1174,6 +1186,7 @@ curl_easy_setopt_ccsid(CURL * curl, CURLoption tag, ...)
case CURLOPT_RTSP_TRANSPORT:
case CURLOPT_SERVICE_NAME:
case CURLOPT_SOCKS5_GSSAPI_SERVICE:
case CURLOPT_SOCKS_PROXY:
case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
case CURLOPT_SSH_KNOWNHOSTS:
case CURLOPT_SSH_PRIVATE_KEYFILE:

View file

@ -657,6 +657,8 @@
d c 0
d CURLPROXY_HTTP_1_0...
d c 1
d CURLPROXY_HTTPS...
d c 2
d CURLPROXY_SOCKS4...
d c 4
d CURLPROXY_SOCKS5...
@ -1258,6 +1260,42 @@
d c 00244
d CURLOPT_KEEP_SENDING_ON_ERROR...
d c 00245
d CURLOPT_PROXY_CAINFO...
d c 10246
d CURLOPT_PROXY_CAPATH...
d c 10247
d CURLOPT_PROXY_SSL_VERIFYPEER...
d c 00248
d CURLOPT_PROXY_SSL_VERIFYHOST...
d c 00249
d CURLOPT_PROXY_SSLVERSION...
d c 00250
d CURLOPT_PROXY_TLSAUTH_USERNAME...
d c 10251
d CURLOPT_PROXY_TLSAUTH_PASSWORD...
d c 10252
d CURLOPT_PROXY_TLSAUTH_TYPE...
d c 10253
d CURLOPT_PROXY_SSLCERT...
d c 10254
d CURLOPT_PROXY_SSLCERTTYPE...
d c 10255
d CURLOPT_PROXY_SSLKEY...
d c 10256
d CURLOPT_PROXY_SSLKEYTYPE...
d c 10257
d CURLOPT_PROXY_KEYPASSWD...
d c 10258
d CURLOPT_PROXY_SSL_CIPHER_LIST...
d c 10259
d CURLOPT_PROXY_CRLFILE...
d c 10260
d CURLOPT_PROXY_SSL_OPTIONS...
d c 00261
d CURLOPT_SOCKS_PROXY...
d c 10262
d CURLOPT_SOCKS_PROXYTYPE...
d c 00263
*
/if not defined(CURL_NO_OLDIES)
d CURLOPT_FILE c 10001
@ -1444,6 +1482,8 @@
d c X'0040002D'
d CURLINFO_HTTP_VERSION... CURLINFO_LONG + 46
d c X'0020002E'
d CURLINFO_PROXY_SSL_VERIFYRESULT... CURLINFO_LONG + 45
d c X'0020002F'
*
d CURLINFO_HTTP_CODE... Old ...RESPONSE_CODE
d c X'00200002'