on 04-21-2011 11:22 AM
Hi All,
I need to create URL connection with HTTPS URL. I can run Main java class successfully in machine which hosted in SAP Java server, but fail to run integrate it with e-commence application. When depployed in to SAP Java server cannot open HttpsURLConnection and always return CalssCastexception. However same code run as Java Main class
Is this can be a (SSL) Handshake? or is this SSL issue?
MyCode:
String httpsURL = "https://encrypted.google.com/";
URL myurl = new URL(httpsURL);
HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
InputStream ins = con.getInputStream();
InputStreamReader isr = new InputStreamReader(ins);
BufferedReader in = new BufferedReader(isr);
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
Thank You
This is purely ssl issue. You can try adding the below logic first.. This code basically sets ssl properties for us.
import java.security.Security;
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Properties properties = System.getProperties();
String handlers = System.getProperty("java.protocol.handler.pkgs");
if (handlers == null) {
// nothing specified yet (expected case)
properties.put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
}
else {
// something already there, put ourselves out front
properties.put("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol|".concat(handlers));
}
System.setProperties(properties);
Below you start your code....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.