Resin配置SSL说明

80酷酷网    80kuku.com

Resin配置SSL说明


Daan











1.0











2004-12-22


























说明:











为Resin服务器配置SSL的访问功能,有几种方法[1]:

1.       在Unix下使用OpenSSL。(http://www.openssl.org/)

2.       使用SUN的JSSE。(http://java.sun.com/products/jsse)

3. ...

我们这里介绍第二种方法,在Windows 2000下的实现。


 


 



 



准备工作:

1.       Windows 2000 Server。

2.       J2SDK 1.4.x。(已经包括了JSSE)

3.       Resin 2.1.x。

4.       JSSE中keytool用法[2]。


 


 



 



步骤:

1.       创建一个服务器证书

a)         下面讲如何使用Sun的keytool来生成一个服务器证书。看下图:







一般来说,keystore密码和mykey主密码应该设置成一样的。

这时,证书文件已经保存在本例中的C:\resin-2.1.11\keys erver.keystore

2.       配置Resin(resin.conf)

Resin的SSL配置需要对<http-server>进行扩展,增加几个新的元素。下表中红色文字为新增部分。其中,key-store-file为上一步中生成的证书文件存放地址(相对resin根目录),key-store-password为上一步中为证书设置的密码。

<caucho.com>

    <security-provider id='com.sun.net.ssl.internal.ssl.Provider'/>











 

<!-- declare a new HTTP server on port 443 (standard port for HTTPS),











      - with SSL enabled -->











 

<http-server>

  <app-dir>doc</app-dir>

 

  <!-- the http port -->

  <http port=80/>

 

  <!-- the srun port, read by both JVM and plugin -->

  <srun host='localhost' port='6802'/>

 

  <http port=443>











    <ssl>true</ssl>











     <key-store-file>keys/server.keystore</key-store-file>











     <key-store-password>YourPasswordHere</key-store-password>











  </http>


 


 



 



测试:

使用上面的配置,启动resin服务,我们可以访问https://localhost。

一个最快的测试方式是新建一个内容如下的JSP文件并访问他:

Secure? <%= request.isSecure() %>


 


 



 



运行/bin/httpd.exe,结果如下:



访问https://localhost/,跳出一个安全警报,选择是。



(如果不想跳出这个安全警报,有几点要做:1 将证书安装到客户端的IE中;2 证书生成时的CN(即名字与姓氏)必须使用服务器的机器名,即DNS名。)


 


 



 



浏览器浏览https://localhost/,效果如下:



浏览https://localhost/isSecure.jsp测试文件



这表示我们配置Resin使用SSL成功。

参考资料:

[1] SSL configuration: http://localhost/ref/ssl-quick.xtp

以及SSL with Resin: http://www.caucho.com/resin-3.0/security/ssl.xtp

[2] Java keytool 工具的作用及使用方法: http://www.ccw.com.cn/htm/center/prog/02_7_8_4.asp



分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: