Tag: 流httpsurlconnection

如何通过setProperty通过代理使用HttpsURLConnection?

网络环境: Https客户端代理服务器 Https服务器 192.168.17.11 192.168.17.22 10.100.21.10 10.100.21.11 ps:没有默认网关的Http客户端,但它可以ping到10.100.21.11 描述: 操作系统:3台主机上的Ubuntu 12.04 Https Client:用java实现(openjdk-6)。有一个网络接口。 代理服务器:Apache2.2。有两个网络接口。 Https服务器:Tomcat6.Have一个网络接口。 我使用两种方法通过代理实现httpsurlconnection : (为方便起见 ,我没有写下关于ssl句柄函数来检查serverTrusted和hostnameVerifier问题。如果需要我会更新。) 1.Proxy类 InetSocketAddress proxyInet = new InetSocketAddress(“10.100.21.11”,80); Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyInet); URL httpsUrl = new URL(“https://192.168.17.22:8443/test”); HttpsURLConnection httpsCon = (HttpsURLConnection) httpsUrl.openConnection(proxy); httpsCon.setDoOutput(true); httpsCon.setDoInput(true); httpsCon.setRequestMethod(“POST”); OutputStream out = httpsCon.getOutputStream(); OutputStreamWriter owriter = new OutputStreamWriter(out); owriter.write(“test”); owriter.flush(); […]