Bug #64862 Support java proxies in StandardSocketFactory
Submitted: 4 Apr 2012 11:25 Modified: 20 Oct 2014 22:06
Reporter: Julian Cable Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S4 (Feature request)
Version: OS:Any
Assigned to: Jess Balint CPU Architecture:Any
Tags: Contribution, firewall, http, https, proxy, socks

[4 Apr 2012 11:25] Julian Cable
Description:
I needed to access a MySQL server which is located in our DMZ and beyond a socks proxy. Previously I have used Perl and the command line client to do this and socksify has worked fine.

I'm migrating my ETL scripts to Apache Camel and don't want to socksify my entire EIP platform, either using socksify or the JVM-wide socksProxyHost/socksProxyPort system properties.

I need a means of setting the socks proxy for the Sql connection.

Connector/J provides a SocketFactory configuration property which can be used to override the socket factory. I cloned StandardSocketFactory and added the required code to support socks, http and https proxies. The socks proxy works just like I'd hoped. I haven't tested the http variants.

How to repeat:
feature request

Suggested fix:
Adding the proxy support to the StandardSocketFactory would be an entirely backwards compatible enhancement which would save other people having to implement a solution themselves.
[4 Apr 2012 11:27] Julian Cable
sample implementation of a proxy aware SocketFactory.

Attachment: SocksSocketFactory.java (application/octet-stream, text), 13.34 KiB.

[4 Apr 2012 11:28] Julian Cable
oops title was a bit wrong
[4 Apr 2012 12:11] Valeriy Kravchuk
Thank you for the feature request and code contributed.
[15 Aug 2014 8:17] Alexander Soklakov
Hi Julian,

Thank you for the interesting report. If you are still interested in it's implemented in Connector/J you need to follow this:

"In order to submit contributions you must first sign the Oracle Contribution Agreement (OCA).
For additional information please check http://www.oracle.com/technetwork/community/oca-486395.html."
[20 Oct 2014 22:06] Daniel So
Support for SOCKS proxy has been added to Connector/J 5.1.34. The following entry has been added to the Connector/J 5.1.34 changelog:

"Connector/J now supports connections to MySQL servers through a SOCKS proxy. Two new configuration properties, socksProxyHost and socksProxyPort, have been introduced to support this new feature; see the entries for them in Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J (http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.htm...) for details. Note that authentication is not directly supported in the current implementation for SOCKS proxy support."