• Post Reply Bookmark Topic Watch Topic
  • New Topic

URL https connection problems, please help!!!  RSS feed

 
jesse harris
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there folks,
I have a problem I was hoping to get some help with.
when trying to get a URL connection
with the https protocol I get a
java.net.MalformedURLException:
unknown protocol: https
my code is as follows
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
out = resp.getWriter();
out.println(System.getProperty("java.protocol.handler.pkgs") + "\n");
String f = req.getParameter("f");
//URL order = new URL("https://wwwcie.ups.com/ups.app/xml/Track", );
URL order = new URL("https", "wwwcie.ups.com", "/ups.app/xml/Track");
I am diong this in WSAD 5
as far as I know the JSSE comes installed,
but do I need to add it to a path or something?
and if I did wouldnt the code throw an exception
when I call the add provider method.
and help/tips apppreciated, I have been trying to get this to work for 3 days.
thanks in advance,
Jesse,
not Jsse.........lol.. wow bad geek joke,
I apologize
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am diong this in WSAD 5
as far as I know the JSSE comes installed,
but do I need to add it to a path or something?

Yes, add the 2 JSSE jars to classpath. I have code similar to yours that works.
Eugene.
 
jesse harris
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
would it be possible for you to elaborate,
I went to suns site and it says that jsse is
integrated into the JavaTM 2 SDK,
Standard Edition, v 1.4.
what 2 jars would I need,
would I need to get them from sun,
and what path do I add them to,
the build path?
or is it server related,
and any help you could give me doing
this in wsad would be ver very much
appreciated.
thanks a lot
Jesse
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

what 2 jars would I need,
would I need to get them from sun,
and what path do I add them to,
the build path?
or is it server related,
and any help you could give me doing
this in wsad would be ver very much
appreciated.

Actually for 1.3 you needed 2 jars, for 1.4 it's just one, -- jsse.jar. Do a search in your JDK installation directory, it should be in jre\lib
Now, I am using JBuilder to build and run my app, but it should be the same for you, -- add jsse.jar to classpath when you run your app:
java -classpath "<your jdk dir>\jre\lib\jsse.jar" yourStartClass
Eugene.
 
jesse harris
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added it to the build path of the project and to the path of the server,
the only jar I could find was sunssl.jar
is this what I need?
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have added it to the build path of the project and to the path of the server,
the only jar I could find was sunssl.jar
is this what I need?

I assume that it is a client client making an HTTPs request, not the server. And again, jsse.jar must be in your classpath, I don't know what your build path is used for.
 
Starix XieXie
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eugene Kononov ,
Did you manage to post or get something from Https website ?
if you do..can you share your code that did that part ??
i got problem.. alwasy.. Untrusted Server Certificate Chain got this message



Thanks in advance
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using 1) J2SDK 1.3 or 2) J2SDK 1.4? If 1), then did you read the JSSE installation instructions and follow them to the letter? If 2), then junk the protocol handler and provider code --- it's built into the runtime.
FWIW, the MalformedURLException indicates that the problem is in the protocol handler setup.
- Peter
 
jesse harris
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I added the line to the java.security file
to add the handler manually and it worked.
thanks for all you help guys,
Jesse
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Did you manage to post or get something from Https website ?
if you do..can you share your code that did that part ??

Yes, there is not much magic about it. Below is the code that I use to connect to my online broker over SSL, to get quotes, place trades, monitor portfolio, all from my own java client (as opposed to HTML interface).

Eugene.
[ January 23, 2003: Message edited by: Eugene Kononov ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!