创建openssl证书和CA的最简单的方法

Posted by zuzhihui in Linux技术 on 2008/08/02 with No Comments

今天打开thunderbird连接到VPS上的dovecot imaps邮件服务器,thunderbird报告说ssl证书过期了。原来是dovecot安装时候自带的证书有效期太短,今天到期了,该更新证书了。

网络上搜索到的大部分方法都是用openssl命令来创建ca和证书,这种方法比较麻烦,容易出错。

我用certtool工具又重新创建了一个ca和一个自认证的openssl证书。过程记录如下:

certtool这个工具包含在gnutls这个包里面,首先要在VPS上安装这个包,在Debian/Ubuntu VPS上运行

apt-get install gnutls-bin gnutls-doc

在CentOS VPS上需要运行:

yum install -y gnutls-utils

创建ca.info文件,内容如下:

cn = rashost
ca
cert_signing_key
expiration_days = 3650

创建CA:

certtool --generate-privkey > ca.key
certtool --generate-self-signed --load-privkey ca.key --template ca.info --outfile ca.cert
certtool -i --infile ca.cert

创建rashost.com.info文件,内容如下:

organization = rashost Inc.
cn = rashost.com
tls_www_server
encryption_key
signing_key
expiration_days = 3650

然后创建证书:

certtool --generate-privkey > rashost.com.key
certtool --generate-certificate --load-privkey rashost.com.key --load-ca-certificate ca.cert --load-ca-privkey ca.key --template rashost.com.info --outfile rashost.com.cert
certtool -i --infile rashost.com.cert

rashost.com.cert是证书文件,rashost.com.key是密钥文件,在dovecot的配置文件里使用这两个文件就可以了。

Back to Top

2007-2017 © 北京瑞豪开源科技有限公司 京ICP备13004995号-2