You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Russ White <ru...@earthlink.net> on 2000/08/09 17:01:22 UTC

SSL and https scheme

I am new to Tomcat, but I just wanted to share a problem I found in creating
a context that uses SSLSocketFactory.

The problem was that when using https to access a servlet or jsp the scheme
in the request object would still be set to http. This was incorrect. The
result is that sometime when redirecting with response.sendredirect() or
similar methods the URL would have http scheme instead of https. Also if you
enter a default url like https://localhost/ it would revert back to http
when serving up index.html. I worked arounf the problem by adding this line:

if (socket instanceof javax.net.ssl.SSLSocket) this.scheme="https";

in tis method:

public void setSocket(Socket socket) throws IOException {
 if( sin==null)
     sin = new RecycleBufferedInputStream ( socket.getInputStream());
 else
     sin.setInputStream( socket.getInputStream());
 in = new BufferedServletInputStream(this);
        this.socket = socket;
     moreRequests = true;
        if (socket instanceof javax.net.ssl.SSLSocket) this.scheme="https";
}

in HttpRequestAdapter

Now everything works fine.

Russ White