2007年10月 存档

tomcat启用apr的情况下使用非自签名证书进行ssl双向认证配置

2007年10月23日,星期二

Tomcat的apr组件是使用JNI用来提升Tomcat的系统性能,在启用apr特性之后,Tomcat的 https功能不能使用JSSE的证书配置,
而需要使用OpenSSL,对于clientAuth的双向认证配置,也与一般方式不同,经过试验,摸索出配置步骤如下:

证书文件的制作步骤如下:

下载并安装openvpn,然后在
C:\Program Files\OpenVPN\easy-rsa下根据readme指导的步骤生成根证书,服务器证书(非自签名证书),客户端证书.

我的具体步骤:
1.命令行下进入 C:\Program Files\OpenVPN\easy-rsa
首先运行init-config.bat
当前目录下会生成openssl.cnf和vars.bat
2.编辑vars,bat,修改以下变量,保存文件.
set KEY_SIZE=2048
set KEY_COUNTRY=CN
set KEY_PROVINCE=GD
set KEY_CITY=ShenZhen
set KEY_ORG=zongbo.Inc
set KEY_EMAIL=lizongbo@618119.com

3.命令行下运行
vars.bat
clean-all
4.创建ca证书
1. vars
2. build-ca
5.创建服务器公匙密码
(由于KEY_SIZE设置成了2048,因此可能需要很长的是时间才能创建,此时可以改回1024)
1. vars
2. build-dh

6.创建服务器证书和key.
1. vars
2. build-key-server www

7.创建客户端证书(创建可导入的格式)
1. vars
2. build-key-pkcs12 lizongbo

以下是整个命令执行的过程

C:\Program Files\OpenVPN\easy-rsa>init-config

C:\Program Files\OpenVPN\easy-rsa>copy vars.bat.sample vars.bat
已复制 1 个文件。

C:\Program Files\OpenVPN\easy-rsa>copy .cnf.sample .cnf
已复制 1 个文件。

C:\Program Files\OpenVPN\easy-rsa>vars.bat

C:\Program Files\OpenVPN\easy-rsa>clean-all
系统找不到指定的文件。
已复制 1 个文件。
已复制 1 个文件。

C:\Program Files\OpenVPN\easy-rsa>vars

C:\Program Files\OpenVPN\easy-rsa>build-ca
Loading ‘screen’ into random state – done
Generating a 2048 bit RSA private key
…………………………………..+++
……………………………………………………………………..
……………………………………………………………………..
…………………….+++
writing new private key to ‘keys\ca.key’
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [CN]:CN
State or Province Name (full name) [GD]:GD
Locality Name (eg, city) [ShenZhen]:ShenZhen
Organization Name (eg, company) [zongbo.Inc]:zongbo.Inc
Organizational Unit Name (eg, section) []:lzb.Inc
Common Name (eg, your name or your server’s hostname) []:ca.lizongbo.com
Email Address [lizongbo@618119.com]:lizongbo@618119.com

C:\Program Files\OpenVPN\easy-rsa>vars

C:\Program Files\OpenVPN\easy-rsa>build-dh
Loading ‘screen’ into random state – done
Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time
………………………………………………..+……………..+…..
……………………………………………………………..+……..
……………………………………………………………………..
………………….+…………………………………………………
……………………………………………………………………..
……………………………………………………………………..
…………………..+…………………………………………..+…..
…………………………………+………………………..+……….
……………………………………………………………..+……..
………………………………………………………….+…………
………………………….+…………………………………………
……………………………………………………………+……….
……………………………………………………………………..
…+…………………………………+………..+……………………
………………………………+…………………………………….
……………………………………………………………………..
.+………………………………………………………………+…..
……………………………………………………………………..
………………………………………………………….+…………
…………………………………………
C:\Program Files\OpenVPN\easy-rsa>vars

C:\Program Files\OpenVPN\easy-rsa>build-key-server www
Loading ‘screen’ into random state – done
Generating a 2048 bit RSA private key
……….+++
…………………………….+++
writing new private key to ‘keys\www.key’
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [CN]:CN
State or Province Name (full name) [GD]:GD
Locality Name (eg, city) [ShenZhen]:ShenZhen
Organization Name (eg, company) [zongbo.Inc]:zongbo.Inc
Organizational Unit Name (eg, section) []:lzb.Inc
Common Name (eg, your name or your server’s hostname) []:www.618119.com
Email Address [lizongbo@618119.com]:lizongbo@618119.com

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:lizongbo
An optional company name []:lzb.cmp
Using configuration from openssl.cnf
Loading ‘screen’ into random state – done
Check that the request matches the signature
Signature ok
The Subject’s Distinguished Name is as follows
countryName :PRINTABLE:’CN’
stateOrProvinceName :PRINTABLE:’GD’
localityName :PRINTABLE:’ShenZhen’
organizationName :PRINTABLE:’zongbo.Inc’
organizationalUnitName:PRINTABLE:’lzb.Inc’
commonName :PRINTABLE:’www.618119.com
emailAddress :IA5STRING:’lizongbo@618119.com
Certificate is to be certified until Sep 17 02:27:21 2017 GMT (3650 days)
Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

C:\Program Files\OpenVPN\easy-rsa>vars

C:\Program Files\OpenVPN\easy-rsa>build-key lizongbo
Loading ‘screen’ into random state – done
Generating a 2048 bit RSA private key
……………+++
……………………+++
writing new private key to ‘keys\lizongbo.key’
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [CN]:CN
State or Province Name (full name) [GD]:GD
Locality Name (eg, city) [ShenZhen]:ShenZhen
Organization Name (eg, company) [zongbo.Inc]:zongbo.Inc
Organizational Unit Name (eg, section) []:lzb.Inc
Common Name (eg, your name or your server’s hostname) []:lizongbo
Email Address [lizongbo@618119.com]:lizongbo@618119.com

Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []:lizongbo
An optional company name []:lzb.cmp
Using configuration from openssl.cnf
Loading ‘screen’ into random state – done
DEBUG[load_index]: unique_subject = “yes”
Check that the request matches the signature
Signature ok
The Subject’s Distinguished Name is as follows
countryName :PRINTABLE:’CN’
stateOrProvinceName :PRINTABLE:’GD’
localityName :PRINTABLE:’ShenZhen’
organizationName :PRINTABLE:’zongbo.Inc’
organizationalUnitName:PRINTABLE:’lzb.Inc’
commonName :PRINTABLE:’lizongbo’
emailAddress :IA5STRING:’lizongbo@618119.com
Certificate is to be certified until Sep 17 02:28:38 2017 GMT (3650 days)
Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

C:\Program Files\OpenVPN\easy-rsa>

证书文件的安装步骤如下:

在IE中 :
在资源管理其中,双击easy-rsa\keys\ca.crt,导入根证书.双击www.crt,导入服务器证书,双击lizongbo.p12,导入客户端证书.

在Firefox中:

主菜单–>工具–>选项–>加密,察看证书–>证书机构->导入,选择ca.crt,导入之后,选中刚导入的证书,然后点”编辑”,将三项新任设置全部打上钩.

切换面板到”web站点”,导入,选择www.crt,导入之后,选中刚导入的证书,然后点”编辑”,选择”信任此证书的认证”

切换到”您的证书”,导入,选择lizongbo.p12, 输入生成证书时设置的密码,导入成功.
(Firefox中如果不首先导入根证书,Firefox会提示-12227错误,”接收到错误或未期望的消息,错误号-12227 “, 与IE的表现不同)
(更多…)

Tags: , , , , ,

在 Spket IDE 1.6.4 中使用 Ext 2.0

2007年10月22日,星期一

Spket是个非常优秀的javascript开发工具,Ext则是非常优秀的javascript库。

IDE 1.6.4中使用Ext 2.0 .

1.下载:

http://www.spket.com/downloads/spket-1.6.4.1.jar

引用页 http://www.spket.com/download.html

http://extjs.com/deploy/ext-2.0-beta1.zip

引用页 http://extjs.com/download
2.运行 java -jar spket-1.6.4.1.jar进行安装

3.解压ext-1.1.1.zip

4.启动 Spket IDE,

5.new Project “testExt”, new File “test.js”

6.将ext-all.js 复制到D:\Documents and Settings\lizongbo\workspace\testExt

7.然后再在test.js里开头加上
/**
* @include “/testExt/-all.js”
*/
testExt为项目名字.

然后再在test.js里写代码就有ext的提示了.

输入Ext,然后按 Alt +/ ,就可以看到语法提示。

Tags: , , ,

在Apache Tomcat上安装WordPress 2.3

2007年10月22日,星期一

在Apache Tomcat上安装Wordpress 2.3

借助quercus这个纯Java PHP引擎,我们可以在Tomcat上安装Wordpress.

1.首先下载

JDK: jdk-6u3-windows-i586-p.exe http://www.mnidc.net/software/java_se/jdk-6u3-windows-i586-p.exe

5.0.45: http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.0/mysql-noinstall-5.0.45-win32.zip

6.0.14: http://www.apache.org/dist/tomcat/tomcat-6/v6.0.14/bin/apache-tomcat-6.0.14.zip

3.1.3: http://quercus.caucho.com/download/quercus-3.1.3.war

2.3: http://wordpress.org/latest.zip

WordPress 2.3 简体中文语言包 第二版: http://wpcn.googlecode.com/files/wordpress-2-3-zh_CN-po-mo.zip

mysql jdbc: http://ftp.ntu.edu.tw/pub/MySQL/Downloads/Connector-J/mysql-connector-java-5.1.0.zip

javamail

2.安装:
运行jdk-6u3-windows-i586-p.exe安装 JDK 到D:\Java\jdk1.6.0_03
配置环境变量JAVA_HOME=D:\Java\jdk1.6.0_03
环境变量Path中加入D:\Java\jdk1.6.0_03\bin;

解压mysql-noinstall-5.0.45-win32.zip为:E:\mysql-5.0.45-win32

解压pache-tomcat-6.0.14.zip到为:D:\Java\apache-tomcat-6.0.14

解压quercus-3.1.3.war为:D:\Java\apache-tomcat-6.0.14\webapps\quercus

解压latest.zip为D:\Java\apache-tomcat-6.0.14\webapps\quercus\wordpress

解压wordpress-2-3-zh_CN-po-mo.zip到 D:\Java\apache-tomcat-6.0.14\webapps\quercus\wordpress\wp-content\language

解压mysql-connector-java-5.1.0.zip得到mysql-connector-java-5.1.0.jar,将其复制到D:\Java\apache-tomcat-6.0.14\webapps\quercus\WEB-INF\lib

将activation.jar和mail.jar复制到D:\Java\apache-tomcat-6.0.14\webapps\quercus\WEB-INF\lib。

4.配置:

将 D:\Java\apache-tomcat-6.0.14\webapps\quercus\wordpress\下的wp-config-sample.php重命名为wp-config.
编辑后的wp-config.php的内容如下:

<?php
// ** MySQL settings ** //
define(‘DB_NAME’, ‘wordpress’); // The name of the database
define(‘DB_USER’, ‘root’); // Your MySQL username
define(‘DB_PASSWORD’, ”); // …and password
define(‘DB_HOST’, ‘localhost’); // 99% chance you won’t need to change this value
define(‘DB_CHARSET’, ‘utf8′);
define(‘DB_COLLATE’, ”);

// You can have multiple installations in one database if you give each a unique prefix
$table_prefix = ‘wp_’; // Only numbers, letters, and underscores please!

// Change this to localize WordPress. A corresponding MO file for the
// chosen language must be installed to wp-content/languages.
// For example, install de.mo to wp-content/languages and set WPLANG to ‘de’
// to enable German language support.
define (‘WPLANG’, ‘zh_CN’);

/* That’s all, stop editing! Happy blogging. */

define(‘ABSPATH’, dirname(__FILE__).’/');
require_once(ABSPATH.’wp-settings.php’);
?>

5.启动:

运行E:\mysql-5.0.45-win32\bin\mysqld.exe
运行D:\Java\apache-tomcat-6.0.14\bin\startup.bat

6.安装设置Wordpress

打开浏览器,访问 http://localhost:8080/quercus/wordpress/wp-admin/install.php

进行安装。

(Tomcat后台此时会报很多异常,这是因为wordpress在检测相关的表是否已经创建)

7.访问

http://localhost:8080/quercus/wordpress/ 可以看到内容显示正常。

(更多…)

Tags: , , , ,