Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem accessing https through ssl connection

 
Geetha Gubendran
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I tried the program. The HTTP is working fine but not https. I enquired our INFRA team. When I set the same proxy in my firewall client, I am able to hit both https and http but when I set the proxy in the code, I am able to hit only http and not https. Then the INFRA guy told me that the proxy that we set using http.proxyHost does not allow the traffic to go beyond the intranet. does this property (http.proxyHost) have any limitations? Can someone suggest how to get over this issue?

import java.net.URL;
import java.net.URLConnection;
import java.security.Security;
import org.apache.commons.codec.binary.Base64;
public class TestSSL {
public static void main(String[] args) {
System.getProperties().put( "proxySet","true" );
System.getProperties().put("http.proxyHost", "XXX");
System.getProperties().put("http.proxyPort", "XXX");


System.out.println("bfr");
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
System.out.println("1");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.out.println("2");
try {


//System.getProperties().put("java.protocol.handler.pkgs", "HTTPClient");
//URL url = new URL("https://www.verisign.com/");



//URL url = new URL("https://apps.telstra.xora.com/xoraapps/services/XoraTimeTrackUtilityServices40?wsdl");
URL url = new URL("http://www.google.com");
//URL url = new URL("https://www.verisign.com");
System.out.println("3");
URLConnection con = url.openConnection();

con.setDoInput( true );
con.setDoOutput( true );
System.out.println("4");
//con.connect();
java.io.InputStream urlfs = con.getInputStream();
System.out.println("5");
System.out.println("Successful Connection Establishment =>"+url.getHost());

} catch (Exception e) {
System.out.println("Print Exception Details =>"+e.toString());
}

}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic