本文是windows平台的ejbCA配置記錄,配置過程中參考了很多網上的資料。在此表示感謝。
參見: http://job2job.blog.163.com/blog/static/1416633120071162154863/
http://www.cnblogs.com/luoxiao/archive/2008/01/12/1035963.html
需要的軟體:
1. JDK1.5.0_9 http://java.sun.com/
2. JBOSS-4.2.2.GA http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=16942&release_id=548923
3. ejbca_3_5_4.zip http://ejbca.sourceforge.net/download.htm
http://sourceforge.net/project/showfiles.php?group_id=39716&package_id=108797
4. apache-ant-1.7.0-bin.zip http://apache.mirror.phpchina.com/ant/binaries/apache-ant-1.7.0-bin.zip
5. mysql5.0
6. jce_policy-1_5_0.zip http://java.sun.com/javase/downloads/index_jdk5.jsp
7. mysql-connector-java-5.0.6.zip http://download.softagency.net/MySQL/Downloads/Connector-J/
1. 設定環境變數
JAVA_HOME = D:\java\jdk
EJBCA_HOME=D:\ejbca
JBOSS_HOME = D:\ejbca\jboss
ANT_HOME = D:\ejbca\apache-ant-1.7.0
PATH =PATH; %JAVA_HOME%\BIN;%JBOSS_HOME%\BIN;%ANT_HOME%\bin;
CLASSPATH= .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib;
2. mysql 的路徑 D:\mysql 使用者名稱和密碼:root,123456
建立資料庫 ejbca 串連該資料庫的使用者名稱和密碼也為root,123456後面配置
3. 把mysql-connector-java-5.0.6-bin.jar拷貝到 D:\ejbca\jboss\server\default\lib
以下是ejbCA的一些設定檔的修改,是參考別人的blog:
將%EJBCA_HOME%\conf\ejbca.properties.sample 複製儲存為 %EJBCA_HOME%\conf\ejbca.properties
將%EJBCA_HOME%\conf\web.properties.sample, 複製儲存為 %EJBCA_HOME%\conf\web.properties,如要設定顯示中文介面要修改如下(紅字為對應修改)
# Defines the available languages by languagecodes separated with a comma (example EN,ZH).
# If you are not sure that you know how to add a new language (languagefile.XX.properties etc),
# we suggest you stick with the default the first time you install if you wan''t to add your own language.
# Otherwise you may not be able to log in to the admin-GUI.
# Default: EN,FR,IT,ES,SE,ZH
web.availablelanguages=ZH,EN,FR,IT,ES,SE
# Default content encoding used to display JSP pages, for example ISO-8859-1, UTF-8 or GBK.
# Default: ISO-8859-1
web.contentencoding=GBK
將%EJBCA_HOME%\conf\database.properties.sample複製儲存為 %EJBCA_HOME%\conf\database.properties,並修改如下(紅字為對應修改)
# Default: hsqldb
database.name=mysql
# The datasource mapping selected for deployment.
# The J2EE server needs to be configured with the appropriate datasource mapping.
# For JBoss this maps to a setting in standardjbosscmp-jdbc.xml and must match the database chosen above.
# All supported mappings are defined below, others can easily be added
# Default: Hypersonic SQL
datasource.mapping=mySQL
# Database connection url.
# This is the URL used to connect to the database, used to configure a new datasource in JBoss.
# Default: jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB
database.url=jdbc:mysql://127.0.0.1:3306/ejbca?characterEncoding=UTF-8
# JDBC driver classname.
# The J2EE server needs to be configured with the appropriate JDBC driver for the selected database
# Default: org.hsqldb.jdbcDriver
database.driver=com.mysql.jdbc.Driver
# Database username.
# Default: sa (works with hsqldb)
database.username=root
# Database password.
# Default: (blank works with hsqldb)
database.password=1234564. jce 解壓縮後,jar覆蓋 jdk/jre/lib/security下的jar
5. ejbca 下 ant bootstrap
cmd到%EJBCA_HOME%目錄下,運行ant bootstrap ,並將產生的%EJBCA_HOME%\dist\下的ejbca.ear拷貝到\%jboss-4.0.5%\server\default\deploy(高版本ejbca不需要,會自動拷貝過去)
6. 啟動jboss。%BOSS_HOME%/run.bat
注意:在ant install之前要啟動mysql資料庫,否則就會無法產生p12檔案。我的mysql是手動啟動,因此,好幾次在ant install之後p12檔案夾下是空的,後來發現是mysql沒有啟動。
ejbca的manual.htm中寫到,ant install只能運行一次。當安裝失敗再重新安裝時,記得把mysql中的ejbca drop後重建立立。
7. 。%EJBCA_HOME%/下ant install
8. 停止JBOSS
9. %EJBCA_HOME%目錄下,運行ant deploy 。將重新部署整個系統,並用密鑰庫配置sevlet容器。
10. 將%EJBCA_HOME%/p12/superadmin.p12認證匯入瀏覽器,預設密碼是ejbca。匯入處理程序為選擇瀏覽器Internet選項->內容選項卡->認證按鈕->匯入按鈕。就會開啟匯入認證的對話方塊。
11. 重新啟動jboss。
12.登入http://localhost:8080/ejbca/
13. 進入adminstrator,瀏覽器會要求你選擇認證。選擇之前置入的adminCA1就可以了。
安裝過程中出現一些錯誤:
對於ejbCA的安裝是否會修改%JAVA_HOME%/jre/lib/security/下的cacerts檔案,我不太確定。看到有人在blog裡說,安裝失敗後要重裝jdk來恢複cacerts,但我發現安裝jdk前後cacerts檔案似乎沒有改變。建議在安裝之前先對該檔案做個備份。
這樣,第一次安裝失敗後就不用重裝jdk,只用恢複該檔案就可以了。