简介:
OpenCA由四个主要部分组成,即CA,RA,PUB,NODE 。简单来说PUB是对外提供服务的接口,用户可以在PUB界面提交自己的注册请求、查询请求等等。RA主要负责来处理经由PUB提交过来的用户请求,来决断是否批准这些请求。CA则根据RA批准的请求来最终签发证书。NODE负责在RA和CA之间传输数据。

 

(1)### Version-1.1.1 安装

首先有几个前提:

第一,操作系统采用RHEL5.3,并且安装时一定要采用全安装模式,保证大部分包都装上;

第二,在域名服务器增加好对ipanelca.eis的解释,指向这台机器的IP

第三,把安装机器的名称,要改成相应的域名名称。比如:ipanelca.eis , 这是我们需要的域名,然后就要
vi /etc/hosts

127.0.0.1 localhost.localdomain localhost
改成
127.0.0.1 ipanelca.eis ipanelca
接着
vi /etc/sysconfig/network

HOSTNAME=localhost.localdomain
改成
HOSTNAME=ipanelca.eis
然后重启机器,看看hostname是否起效了

第四,如果系统有apahce,需要先卸载掉rpm -e httpd-2.2.3-22.el5 --nodeps。
然后需要确保apache(httpd-2.2.10)版本是手工安装在以下目录:/usr/local/apache2 , 安装步骤参照apache.txt

shell> tar xzvf httpd-2.2.10.tar.gz
shell> cd httpd-2.2.10

如果要装suexec支持cgi的sudo,则:
shell> ./configure --prefix=/usr/local/apache2 --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/usr/local/apache2/cgi-bin

如果是媒体服务器的用户media,需要以下:
shell> ./configure --prefix=/usr/local/apache2 --enable-suexec --with-suexec-caller=media --with-suexec-docroot=/usr/local/apache2/cgi-bin

否则一般情况下:
shell> ./configure --prefix=/usr/local/apache2 --enable-module=so --enable-module=rewrite --enable-ssl=static --with-ssl=/usr/local/ssl //(ssl开启https)

shell> make
shell> make install

echo "/usr/local/apache2/bin/apachectl start" >>/etc/rc.local


/usr/local/apache2/bin/apachectl start
如果碰到:httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
则修改httpd.conf的#ServerName www.example.com:80 为:
ServerName 192.168.10.253:80


设置开机自启动
cd /usr/local/apache2/bin/
cp apachectl /etc/rc.d/init.d/httpd
chmod 700 /etc/rc.d/init.d/httpd

 

第五,运行rpm -qa | grep mysql,如果系统装有缺省的mysql-5.0.45,也需要先卸载掉。卸载步骤如下:(一定要严格按照这两步操作)
rpm -e mysql-5.0.45-7.el5 --nodeps
rpm -e mysql-server-5.0.45-7.el5

 

------ 下面开始正式安装CA系统 --------

rpm -qa | grep perl-XML-Parser ,没有就安装
rpm -ivh perl-XML-Parser-2.34-6.1.2.2.1.i386.rpm
rpm -qa | grep perl-DBI ,没有就安装
rpm -ivh perl-DBI-1.52-2.el5.i386.rpm

ll /usr/local/mysql/lib/libmysqlclient.so.15
如果没有,需要先安装mysql-5.0.84
cd /usr/local
gunzip < /root/abiao-disk/mysql/mysql-5.0.84-linux-i686-glibc23.tar.gz | tar xvf -
ln -s mysql-5.0.84-linux-i686-glibc23 mysql


-------------初始化mysql-------- -

shell> ./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/
shell> chown -R root .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> cd support-files/

shell> cp my-huge.cnf /etc/my.cnf

shell> vi /etc/my.cnf
在[mysqld]部分写入:

同时把skip-federated 这行加上#
#skip-federated
同时把port= 3306这行改为:

 

注意:必须再次确保 mysql用户是对数据库data目录内的所有文件具有写的权限(否则待会启动mysql会失败)
chmod -R +w /usr/local/mysql/data

--------------设置自启动:------------
要手动安装mysql.server,用名称mysql将它复制到/etc/init.d目录,然后将它变为可执行文件。只需要将位置更改为mysql.serveris所在并执行这些命令的相应目录:
shell> cd /usr/local/mysql/support-files/
shell> cp mysql.server /etc/init.d/mysql
shell> chmod +x /etc/init.d/mysql


先手工在数据库里创建好openca数据库
用户:openca 密码:openca

cd /usr/lib
ln -s /usr/local/mysql/lib/libmysqlclient.so.15 libmysqlclient.so.15
ll | grep mysql

rpm -qa | grep perl-DBD-MySQL ,没有就安装
rpm -ivh --nodeps perl-DBD-MySQL-3.0007-2.el5.i386.rpm

tar xzvf openca-tools-1.3.0.tar.gz
cd openca-tools-1.3.0
./configure --prefix=/usr/local/openca-tools
make clean
make
make install

tar -xzvf openca-base-1.1.1.tar.gz
cd openca-base-1.1.1
./configure --prefix=/usr/local/openca --with-openca-tools-prefix=/usr/local/openca-tools --with-httpd-user=daemon --with-httpd-group=daemon --with-httpd-fs-prefix=/usr/local/apache2 --with-htdocs-fs-prefix=/usr/local/apache2/htdocs/pki --with-db-name=openca --with-db-type=mysql --with-service-mail-account="webmaster@ipanel.cn"


如果碰到停留在checking getting latest version information...不动时,需要
vi configure
注释掉以下5行,不做最新版本检查即可过去
ret=`wget --version >/dev/null 2>/dev/null; echo $?`
if [ "$ret" = "0" ] ; then
service=`echo ${service_mail_account} | sed "s|support@pki.openca.org||"`
`wget -nd --delete-after -q "http://www.openca.org/alby/checkver?prj=openca;ver=$VERSION;org=${ca_organization};email=${service};os=${DIST_NAME};osver=${DIST_VERSION};act=OP039432012211SSPP" 2>/dev/null`
fi

make

如果碰到Building (DB_File::182) ... ERROR::Can not build module
需要先安装:
rpm -ivh db4-devel-4.3.29-9.fc6.i386.rpm

make install-offline install-online
cd /root/abiao-disk/openca/openca-base-1.1.1-补丁/
cp User.pm /usr/local/openca/lib/openca/perl_modules/perl5/OpenCA/User.pm
cp initServer /usr/local/openca/lib/openca/functions/initServer

先手工在数据库里创建好openca数据库
用户:openca 密码:openca
接着
vi /usr/local/openca/etc/openca/config.xml
修改相应的数据库连接参数(不用改,默认都是账号密码默认都是openca)


cd /usr/local/openca/etc/openca
./configure_etc.sh

cd /usr/local/openca/var/openca/log
chown daemon:daemon xml_cache.log

/usr/local/openca/etc/init.d/openca start
输入密码


------ 修改一些openssl的兼容性配置,这个必须改的 --------
主要因为(1)RHEL5.3版本的openssl-0.9.8e-7.el5不支持签名算法sha256,后果是IE等浏览器不认该CA签发的根证书
(2)让颁发的所有证书都保持10年,免得用缺省的1年就得重颁

vi /usr/local/openca/etc/openca/openssl/openssl.cnf
把所有的
default_md = sha256
都修改成
default_md = sha1
把所有的
default_days = 365
都修改成
default_days = 3650

接着
cd /usr/local/openca/etc/openca/openssl/openssl
打开所有的Role的.conf文件,
把所有的
default_md = sha256
都修改成
default_md = sha1
把所有的
default_days = 365
都修改成
default_days = 3650

vi CA_Operator.conf
vi Cross_CA.conf
vi Domain_Controller.conf
vi Mail_Server.conf
vi OCSP_Server.conf
vi PRQP_Server.conf
vi RA_Operator.conf
vi Sub-CA.conf
vi User.conf
vi ×××_Server.conf
vi Web_Server.conf


/usr/local/openca/etc/init.d/openca stop
/usr/local/openca/etc/init.d/openca start

 

vi /usr/local/apache2/conf/httpd.conf
把 <Directory "/usr/local/apache2/htdocs"> 段下的:
Options Indexes FollowSymLinks
修改为
Options FollowSymLinks

/usr/local/apache2/bin/apachectl restart

 


用浏览器访问:http://ipanelca.eis/pki/ca
如果出现异常,可以查看/usr/local/openca/var/openca/log/stderr.log排错
如果出现的是:Issuing rollback() for database handle being DESTROY'd without explicit disconnect() at /usr/local/openca/lib/openca/perl_modules/perl5/OpenCA/DBI.pm line 900.
根据使用经验这个错误可以忽略,不影响正常的使用和访问CA系统

 

至此,CA系统安装完毕。剩下的工作需要对CA系统进行初始化(特别注意:这些初始化只需要做一次,以后不能再执行了,除非你在有把握的情况下重构整个CA系统):
访问http://ipanelca.eis/pki/ca
登陆用户:admin
登陆密码:你在安装时第一次启动设置的密码


(1)进入:PKI Init & Config -> Initialization -> DB, Key and Cert Init
(2)点击 Initialize Database
完成后,就可以看到openca数据库建立了8个空表:ca_certificate certificate crl crr messages request user user_data

(3)点击 Generate new CA secret key
其中 Encryption algorithm (AES,DES3,etc..) 选 aes256
其中 Asymmetric algorithm (rsa, dsa) 选 rsa
其中 CA key size (in bits) 选 8192

(4)点击 Generate new CA Certificate Request (use generated secret key)
其中 Domain Component [DC] (eg., org or net) 填 cn
其中 Domain Component [DC] (eg., openca or mydomain) 填 ipanel
其中 Domain Component [DC] (eg., pki or subdomain) 填 pki
其中 Common Name (e.g., CertAuth 1) 填 iPanelCARoot
其中 Organizational Unit Name (e.g. MyUnit) 填 iPanel
其中 Organization (e.g. OpenCA Labs) 填 OpenCA Labs
其中 Locality (e.g., Modena) 填 ShenZhen
其中 State/Province (e.g., NY) 填 GuangDong
其中 ISO 3166 Country Code (e.g. IT, DE, US, ...) 填 CN

(5)点击 Self Signed CA Certificate (from altready generated request)
其中 Serial Number (eg., 00, a0d399) 填 06
其中 Certificate Validity (Days) 填 3660
其中 Subject Alt Name 选 email 填 webmaster@ipanel.cn
其中 Extensions 选 Self Signed CA

(6)点击 Rebuild CA Chain


------ 配置RA, 因为RA要求必须用https才能访问 --------

先给该服务器颁发一个服务器证书,证书颁给ipanelca.eis,步骤如下:
访问http://ipanelca.eis/pki/ca
(一)进入:PKI Init & Config -> Initialization -> RA Certificate
(1)点击 Create a new request
其中 First Name 填 ipanelca
其中 Last Name 填 .eis
其中 Birth Date (dd/mm/yyyy) 放空
其中 User Identifier (if any) 放空
其中 E-Mail Address webmaster@ipanel.cn
其中 Department 填 IT
其中 Phone Number 填 075582374434
其中 Address (N. and Street) 填 YanHeBeiLu1002RuiSiGuoJiDaSha12F
其中 City 填 ShenZhen
其中 State (or Province) 填 GuangDong
其中 Zip Code 填 518002
其中 Country 填 China

(2)点击 Continue
其中 Subject Name 特别注意看中间会有个空格的,需要把这个空格删除掉。比如:ipanelca .eis , 要改成 ipanelca.eis
其中 Certificate Request Group 选 Users
其中 E-Mail 填 webmaster@ipanel.cn
其中 User ID (if any) 放空
其中 Certificate Template 选 WebServer
其中 Selected Registration Authority 选 Trustcenter itself
其中 Level of Assurance 选 Medium
其中 Key Generation Mode 选 Server(Our Server)

(3)点击 Continue
其中 Signature Scheme 选 RSA
其中 Key Strength 选 Strongest
其中 PIN (Min. 5 chars) 统一都填 ipanelca

(4)点击 Continue
(5)再点击 Continue
(6)点击 Generate Request ,然后需要等比较长时间,要有点耐心,直到出来一个有"Print"按钮的界面

(二)进入:PKI Init & Config -> Initialization -> RA Certificate
(1)点击 Issue the certificate
(2)点击 Issue certificate

(三)进入:PKI Init & Config -> Initialization -> RA Certificate
(1)点击 Handle the certificate
(2)点击 More Info...
(3)Certificate and Keypair 选择 SSLeay(mode_ssl) ,然后点击Download

提示输入密码,为上面统一填的:ipanelca

(4)用文本编辑器(比如:UltraEdit)新建文件:server.crt 和 server.key
接着把-----BEGIN CERTIFICATE----- 和 -----END CERTIFICATE----- 之间的东西连同BEGIN END本身一起copely进入server.crt

接着把-----BEGIN RSA PRIVATE KEY----- 和 -----END RSA PRIVATE KEY----- 之间的东西连同BEGIN END本身一起copy进入server.key

然后
cd /usr/local/apache2/conf
copy server.crt 和 server.key 到该目录下
chmod 600 server.key
vi httpd.conf
打开 #Include conf/extra/httpd-ssl.conf 的注释,让ssl起作用

/usr/local/apache2/bin/apachectl restart
测试:https://ipanelca.eis/pki/ra

此时会碰到说不受信任的证书,这是正常的。
然后为了获得信任,需要导入CA根证书:
访问http://ipanelca.eis/pki/pub
(一)进入:PKI Info -> Get CA Certificate
(1)点击 CA certificate in format CRT
(2)把下载下来的cacert.crt 改名为 iPanelCARoot.crt,这个就是CA根证书了
(5)然后就可以在浏览器导入该iPanelCARoot.crt


导入完证书后,关闭浏览器再打开,访问https://ipanelca.eis/pki/ra 就正常了。


至此,整个CA系统初始化完毕。再次强调一下:这些初始化只需要做一次,以后不能再执行了,除非你在有把握的情况下重构整个CA系统 .

 

------ CA系统的重要保存信息,一定要注意保存和备份这个私钥,这是一切的根本 --------
根CA私钥
/usr/local/openca/var/openca/crypto/keys/cakey.pem
根证书
/usr/local/openca/var/openca/crypto/cacerts/cacert.der
/usr/local/openca/var/openca/crypto/cacerts/cacert.pem
/usr/local/openca/var/openca/crypto/cacerts/cacert.txt


=================================================================
============================================================
下面是给不同的服务进行颁发证书或者签名使用步骤 。。。Good Luck !


------ 安装AD Server证书 --------

先增加一个AD Server的Role:
访问http://ipanelca.eis/pki/ca
进入 PKI Init & Config -> Configuration -> View Roles
点击 Add a role
填入 AD Server
点击 Create this Role

cd /usr/local/openca/etc/openca/openssl/openssl
vi AD_Server.conf

countryName = supplied
修改成
countryName = optional
否则在签发证书时会报错
再把
countryName_default = de
修改成
countryName_default = cn
再把
default_md = sha256
修改成
default_md = sha1
再把
default_days = 365
修改成
default_days = 3650

/usr/local/openca/etc/init.d/openca stop
/usr/local/openca/etc/init.d/openca start

Ad Sever的证书颁发和安装位置:
颁发证书给:ipanel-exchange.ex.ipanel.cn (注意,这里要根据AD Server的hostname来颁发证书,比如这里是ipanel-exchange,则AD Server必须命名为ipanel-exchange)


一、访问pub填写证书申请表单,提交

访问http://ipanelca.eis/pki/pub
(一)进入:My Certificates -> Request a Certificate
(1)点击 Browser Certificate Request
其中 First Name 填 ipanel-exchange
其中 Last Name 填 .ex.ipanel.cn
其中 Birth Date (dd/mm/yyyy) 放空
其中 User Identifier (if any) 放空
其中 E-Mail Address webmaster@ipanel.cn
其中 Department 填 IT
其中 Phone Number 填 075582374434
其中 Address (N. and Street) 填 YanHeBeiLu1002RuiSiGuoJiDaSha12F
其中 City 填 ShenZhen
其中 State (or Province) 填 GuangDong
其中 Zip Code 填 518002
其中 Country 填 China
(2)点击 Continue
其中 Subject Name 特别注意看中间会有个空格的,需要把这个空格删除掉。比如:ipanelca .eis , 要改成 ipanelca.eis
其中 Certificate Request Group 选 Users
其中 E-Mail 填 webmaster@ipanel.cn
其中 User ID (if any) 放空
其中 Certificate Template 选 AD Server
其中 Selected Registration Authority 选 Trustcenter itself
其中 Level of Assurance 选 Medium
其中 Key Generation Mode 选 Server(Our Server)
(3)点击 Continue
其中 Signature Scheme 选 RSA
其中 Key Strength 选 Base
其中 PIN (Min. 5 chars) 统一都填 ipanelca
(4)点击 Continue
(5)再点击 Continue
(6)点击 Generate Request ,然后需要等比较长时间,要有点耐心,直到出来一个有"Print"按钮的界面

二、RA操作员可以对该请求进行审核。
访问https://ipanelca.eis/pki/ra
(二)进入:RA Operations -> Certification Requests -> New
(1)点击 Search
(2)点击 ipanel-exchange.ex.ipanel.cn这行
(3)点击 Approve Request without Signing

三、RA批准该申请后,CA颁发给自己的RA操作员证书进行签名,提交。
访问http://ipanelca.eis/pki/ca
(三)进入:CA Operations -> Certification Requests -> Approved
(1)点击 ipanel-exchange.ex.ipanel.cn这行
(3)点击 Issue certificate

访问http://ipanelca.eis/pki/pub
(四)进入:Information -> Valid Certificates
(1)点击 ipanel-exchange.ex.ipanel.cn这行
(2)点击 More Info...
(3)Certificate and Keypair 选 PKCS#12,然后点击Download
(4)把下载下来的文件更名为:ipanel-exchange.ex.ipanel.cn.p12
接着到AD服务器安装,有两个地方:
第一、AD的证书更新
验证计算机的个人存储区中安装了证书。若要这样做,请按照下列步骤操作:
启动 Microsoft 管理控制台 (MMC)。
添加证书管理单元来管理本地计算机上的证书。
展开 证书 (本地计算机),展开 个人,然后再展开 证书。
在个人存储区中应存在新的证书。在 证书属性 对话框中显示的预期的目的是 服务器身份验证。此证书颁发给计算机的完全合格的主机名。

客户端验证:
可用LdapAdminExe-1.1\LdapAdmin.exe工具,填入参数为:
Host:192.168.45.242
Base:dc=ex,dc=ipanel,dc=cn
Username:cn=Administrator,cn=Users,dc=ex,dc=ipanel,dc=cn

(2)Exchange的证书更新
进入IIS服务管理器,在“Web站点”点右键,然后单击“属性”,单击“目录安全性”选项卡,单击“服务器证书”启动 Web 服务器证书向导
(注意:在向导执行到第二步“选择此网站使用的方法”时,选择第四项“从.pfx文件导入证书(M)”,然后选择刚才下载的ipanel-exchange.ex.ipanel.cn.p12导入即可)

客户端验证:
访问https://ipanel-exchange.ex.ipanel.cn/owa/

 


------ 配置代码签名 --------

先增加一个Code-Sign的Role:
访问http://ipanelca.eis/pki/ca
进入 PKI Init & Config -> Configuration -> View Roles
点击 Add a role
填入 Code-Sign
点击 Create this Role


cd /usr/local/openca/etc/openca/openssl/openssl
vi Code-Sign.conf

countryName = supplied
修改成
countryName = optional
否则在签发证书时会报错
再把
countryName_default = de
修改成
countryName_default = cn
再把
default_md = sha256
修改成
default_md = sha1
再把
default_days = 365
修改成
default_days = 3650

/usr/local/openca/etc/init.d/openca stop
/usr/local/openca/etc/init.d/openca start

 

代码签名步骤:
从WEB界面下载证书CodeSign3_12.cer
从WEB界面下载证书CodeSign_06_certificate.p12
进入E:\network-management\CA\目录
openssl pkcs12 -nocerts -nodes -in CodeSign3_12.p12 -out CodeSign3_12.key
拷贝CodeSign_06_certificate.key到pvktool目录,并进入该目录
./pvk.exe -nocrypt -topvk -in CodeSign3_12.key -out CodeSign3_12.pvk
进入E:\network-management\CA\SignTool目录,运行signcode.exe进行签名

 

=========================================================================================================================
(2)启动和关闭

注意,只能采用root用户手工启动,不能加入到/etc/rc.local , 因为一些目录权限是需要daemon运行的

/usr/local/openca/etc/init.d/openca stop
/usr/local/openca/etc/init.d/openca start (注意,有时可能会碰到一些异常,比如web上提示无权限等,可以先运行一次stop再start,这个也是权限问题)

 

=========================================================================================================================
(3)#### Version-0.9.1.8 的安装

tar xzvf openca-0.9.1-8.tar.gz
cd openca-0.9.1.8/
./configure --prefix=/usr/local/openca0918ca --with-web-host=localhost --with-ca-organization=”iPanel” --with-ca-country=CN --with-ca-locality=GD --with-httpd-user=daemon --with-httpd-group=daemon --with-httpd-fs-prefix=/usr/local/apache2 --with-hierarchy-level=ca --with-service-mail-account="webmaster@ipanel.cn"
make clean
make
make install-ca

./configure --prefix=/usr/local/openca0918ra --with-web-host=localhost --with-ca-organization=”iPanel” --with-ca-country=CN --with-ca-locality=GD --with-httpd-user=daemon --with-httpd-group=daemon --with-httpd-fs-prefix=/usr/local/apache2 --with-hierarchy-level=ra --with-service-mail-account="webmaster@ipanel.cn"
make clean
make
make install-ra
make install-pub
make install-node

cd /usr/local/openca0918ca/OpenCA/etc/servers
vi ca.conf 和 ca_node.conf
把:
"/dev/fd0"
的地方都修改成:
"/usr/local/openca0918ca/OpenCA/var/opencadataex.tar"

cd /usr/local/openca0918ra/OpenCA/etc/servers
vi ra_node.conf
把:
"/dev/fd0"
的地方都修改成:
"/usr/local/openca0918ca/OpenCA/var/opencadataex.tar"

最后,颁发“代码签名”证书,需要新建一类Role,该Role颁发的证书的用途可以用于“所有”,这样才可以代码签名 。