You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Hari <ha...@kumaran.com> on 2003/01/07 10:11:05 UTC

Accessing Secured Site from within Tomcat.

Hi Everyone!

Greetings!

I have a problems with Tomcat (4.0.4) while accessing a secured site from
inside a JSP or Servlet.  Please find the code (JSP) below.  However, when I
execute the code as a standalone Java Program, I get the expected result.
But inside Tomcat, I get "unknown protocol: https" error.

1. I put the three jar files in common/lib folder of Tocmat.
2. I added the security provider. (com.sun.net.ssl.internal.ssl.Provider)
3. Set the required System properties.

I expect you'll help me to get out this problem.

Thanks and Regards,

Hari.

PS: Kindly CC me (harir@kumaran.com) in your replies as I'm not the
subscriber to either list.


Here is the Stack Trace:
*----------------------*
java.net.MalformedURLException: unknown protocol: https
	at java.net.URL.(URL.java:480)
	at java.net.URL.(URL.java:376)
	at java.net.URL.(URL.java:330)
	at org.apache.jsp.https$jsp._jspService(https$jsp.java:69)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
<snip>..


Here is the (simple) JSP code I use:
*----------------------------------*
<%@ page language="java"
import="java.lang.*,java.net.*,java.util.*,HTTPClient.*" %>
<%
      System.getProperties().put( "java.protocol.handler.pkgs",
					"com.sun.net.ssl.internal.www.protocol");
      System.getProperties().put( "javax.net.debug",
					"all");
	System.getProperties().put( "javax.net.ssl.trustStore",
					"d:\\work\\ssl\\cacert.dat");
	System.getProperties().put( "javax.net.ssl.trustStorePassword",
					"changeit");
      java.security.Security.addProvider(
			new com.sun.net.ssl.internal.ssl.Provider());

	URL url = new URL( "https://prasanna/getProperties");
	HTTPConnection con = new HTTPConnection( url);
	HTTPResponse   rsp = con.Get( "/getProperties");
	System.err.println( "Received Code: " + rsp.getStatusCode());
	System.err.println( "Received Message: "+rsp.getReasonLine());
      String data = rsp.getText();
      System.err.println( data);
%>
<%= data %>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>