···11+## sockhole
22+33+`sockhole` is a decrypting
44+[SOCKS](https://en.wikipedia.org/wiki/SOCKS)
55+proxy.
66+When it receives a request to make a connection to a port listed in its
77+`TLS_PORTS` list, it will establish the encrypted connection itself, verify the
88+TLS certificate, and then proxy decrypted data to the client as if the
99+connection were made to a plaintext service.
1010+1111+This is intended to support old software/equipment which supports SOCKS proxies
1212+but does not support SSL/TLS or modern ciphers.
1313+That software can establish a plaintext connection over a trusted LAN
1414+connection to a local machine running `sockhole`, and the `sockhole` proxy can
1515+establish a secure tunnel over the public internet.
1616+1717+For example, a computer running a POP3 client with SOCKS proxy support but no
1818+SSL support can connect to a remote POP3 server over TLS just by switching the
1919+port configured in the POP3 client to 995 (POP3S).
2020+2121+### Installation
2222+2323+ server$ bundle install --path vendor/bundle
2424+2525+### Use
2626+2727+ server$ bundle exec ruby sockhole.rb
2828+2929+### Client Examples
3030+3131+#### Curl
3232+3333+`curl` should be instructed to use the `http` protocol on port 443, not
3434+`https`, or else it will expect encrypted data to come through the SOCKS proxy.
3535+However, when specifying a URL of `http://example.com:443/`, `curl` will send a
3636+header of `Host: example.com:443` which may cause problems on the server end
3737+with it not matching a configured virtual host.
3838+The `-H` option can be used to override the sent `Host` header to remove the
3939+port:
4040+4141+ server$ bundle exec ruby sockhole.rb
4242+ [2020-11-12 08:47:24 -0600] [I] [server] listening on 192.168.1.1:1080
4343+4444+ client$ curl -H "Host: example.com" --preproxy socks5h://192.168.1.1 http://example.com:443/
4545+ <!doctype html>
4646+ ...
4747+4848+When connecting to a TLS host with an invalid certificate, `sockhole` will reject
4949+the client before it sends any data.
5050+5151+ client$ curl -H "Host: wrong.host.badssl.com" --preproxy socks5h://192.168.1.1 http://wrong.host.badssl.com:443/
5252+ curl: (97) connection to proxy closed
5353+5454+#### nc
5555+5656+ client$ nc -x 192.168.1.1 imap.fastmail.com imaps
5757+ * OK IMAP4 ready