You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Wesley Hall <we...@prociss.co.uk> on 2003/08/10 22:23:57 UTC

Embedded tomcat with HTTPS

Hello,
      Myself and a collegue are currently working on an open source
application, part of which involves embedding a servlet engine. I have read
through some tutorials and the API docs for tomcat and began development of
a class structure to provide this.

I have, however come across a problem with my https connector. I currently
have code that looks like this..

Connector httpsConnector = embeddedTomcat.createConnector(null,
configuration.getHttpsPort(), true);
httpsConnector.setScheme("https");
SSLServerSocketFactory serverSocketFactory = new SSLServerSocketFactory();
serverSocketFactory.setKeystoreFile(configuration.getKeystoreFile());
serverSocketFactory.setKeystorePass("antares");
httpsConnector.setFactory(serverSocketFactory);
embeddedTomcat.addConnector(httpsConnector);
connectors.add(httpsConnector);

configuration is a instance of a simple bean, getHttpsPort() returns 443,
getKeystoreFile() returns the path to the keystore (generated as per the
SSL-Howto doc). The location of the keystore is validated elsewhere in the
code using a File object and a call to .isFile() and .canRead(), both of
which return true when running this code.

However... i am finding that although http://localhost:443 works perfectly,
https://localhost leaves the browser (MSIE) whirring away for 30 seconds or
so before displaying 'cannot find server'. With the former i get plenty of
information in the logs but the latter adds nothing at all to the logs,
making this problem very difficult to debug. I can change the keystore pass
to any value and there is no appreciable difference.

Im happy to provide any more information as required...

Would a kind sameritan type point me in the write direction as to what may
be causing this issue?

Regards Wesley I. Hall.

P.S. I thought long and hard on whether this belonged on dev or user, but
since we are discussing actually class structure i finally decided that dev
would probably be more appropriate. If i was wrong on that descision, you
have my sincere apologies.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Embedded tomcat with HTTPS

Posted by Bill Barker <wb...@wilshire.com>.
I'm going to assume that you're using 4.1.x.  In this case, you are using
the wrong Factory.  You want something like:

  Connector httpsConnector = embeddedTomcat.createConnector(null,

configuration.getHttpsPort(), true);
  CoyoteServerSocketFactory serverSocketFactory =

(CoyoteServerSocketFactory)httpsConnector.getFactory();
  serverSocketFactory.setKeystoreFile(configuration.getKeystoreFile());
  serverSocketFactory.setKeystorePass("antares");

----- Original Message ----- 
From: "Wesley Hall" <we...@prociss.co.uk>
To: <to...@jakarta.apache.org>
Sent: Sunday, August 10, 2003 1:23 PM
Subject: Embedded tomcat with HTTPS


> Hello,
>       Myself and a collegue are currently working on an open source
> application, part of which involves embedding a servlet engine. I have
read
> through some tutorials and the API docs for tomcat and began development
of
> a class structure to provide this.
>
> I have, however come across a problem with my https connector. I currently
> have code that looks like this..
>
> Connector httpsConnector = embeddedTomcat.createConnector(null,
> configuration.getHttpsPort(), true);
> httpsConnector.setScheme("https");
> SSLServerSocketFactory serverSocketFactory = new SSLServerSocketFactory();
> serverSocketFactory.setKeystoreFile(configuration.getKeystoreFile());
> serverSocketFactory.setKeystorePass("antares");
> httpsConnector.setFactory(serverSocketFactory);
> embeddedTomcat.addConnector(httpsConnector);
> connectors.add(httpsConnector);
>
> configuration is a instance of a simple bean, getHttpsPort() returns 443,
> getKeystoreFile() returns the path to the keystore (generated as per the
> SSL-Howto doc). The location of the keystore is validated elsewhere in the
> code using a File object and a call to .isFile() and .canRead(), both of
> which return true when running this code.
>
> However... i am finding that although http://localhost:443 works
perfectly,
> https://localhost leaves the browser (MSIE) whirring away for 30 seconds
or
> so before displaying 'cannot find server'. With the former i get plenty of
> information in the logs but the latter adds nothing at all to the logs,
> making this problem very difficult to debug. I can change the keystore
pass
> to any value and there is no appreciable difference.
>
> Im happy to provide any more information as required...
>
> Would a kind sameritan type point me in the write direction as to what may
> be causing this issue?
>
> Regards Wesley I. Hall.
>
> P.S. I thought long and hard on whether this belonged on dev or user, but
> since we are discussing actually class structure i finally decided that
dev
> would probably be more appropriate. If i was wrong on that descision, you
> have my sincere apologies.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>