HTTPS证书制作
2016-03-22 11:11
465 查看
openssl 安装可参照之前文章
1、
mkdir /etc/ssl/xip.io
openssl genrsa -out /etc/ssl/xip.io/xip.io.key 1024
openssl req -new -key /etc/ssl/xip.io/xip.io.key -out /etc/ssl/xip.io/xip.io.csr
> Country Name (2 letter code) [AU]:US
> State or Province Name (full name) [Some-State]:Connecticut
> Locality Name (eg, city) []:New Haven
> Organization Name (eg, company) [Internet Widgits Pty Ltd]:SFH
> Organizational Unit Name (eg, section) []:
> Common Name (e.g. server FQDN or YOUR name) []:*.xip.io
> Email Address []:
> Please enter the following 'extra' attributes to be sent with your certificate request
> A challenge password []:
> An optional company name []:
openssl x509 -req -days 365 -in /etc/ssl/xip.io/xip.io.csr -signkey /etc/ssl/xip.io/xip.io.key -out /etc/ssl/xip.io/xip.io.crt
cat /etc/ssl/xip.io/xip.io.crt /etc/ssl/xip.io/xip.io.key | tee /etc/ssl/xip.io/xip.io.pem
2、
首先得安装OpenSSL软件包openssl,安装了这个软件包之后,我们可以做这些事情:
o Creation of RSA, DH and DSA Key Parameters # 创建密钥 key
o Creation of X.509 Certificates, CSRs and CRLs # 创建证书
o Calculation of Message Digests #
o Encryption and Decryption with Ciphers # 加密、解密
o SSL/TLS Client and Server Tests # SSL 服务器端/客户端测试
o Handling of S/MIME signed or encrypted Mail # 处理签名或加密了的邮件
1、生成RSA密钥的方法
openssl genrsa -des3 -out privkey.pem 2048
这个命令会生成一个2048位的密钥,同时有一个des3方法加密的密码,如果你不想要每次都输入密码,可以改成:
-openssl genrsa -out privkey.pem 2048
建议用2048位密钥,少于此可能会不安全或很快将不安全。
2、生成一个证书请求
-openssl req -new -key privkey.pem -out cert.csr
这个命令将会生成一个证书请求,当然,用到了前面生成的密钥privkey.pem文件
这里将生成一个新的文件cert.csr,即一个证书请求文件,你可以拿着这个文件去数字证书颁发机构(即CA)申请一个数字证书。CA会给你一个新的文件cacert.pem,那才是你的数字证书。
如果是自己做测试,那么证书的申请机构和颁发机构都是自己。就可以用下面这个命令来生成证书:
-openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
这个命令将用上面生成的密钥privkey.pem生成一个数字证书cacert.pem
3、使用数字证书和密钥
有了privkey.pem和cacert.pem文件后就可以在自己的程序中使用了,比如做一个加密通讯的服务器
1、
mkdir /etc/ssl/xip.io
openssl genrsa -out /etc/ssl/xip.io/xip.io.key 1024
openssl req -new -key /etc/ssl/xip.io/xip.io.key -out /etc/ssl/xip.io/xip.io.csr
> Country Name (2 letter code) [AU]:US
> State or Province Name (full name) [Some-State]:Connecticut
> Locality Name (eg, city) []:New Haven
> Organization Name (eg, company) [Internet Widgits Pty Ltd]:SFH
> Organizational Unit Name (eg, section) []:
> Common Name (e.g. server FQDN or YOUR name) []:*.xip.io
> Email Address []:
> Please enter the following 'extra' attributes to be sent with your certificate request
> A challenge password []:
> An optional company name []:
openssl x509 -req -days 365 -in /etc/ssl/xip.io/xip.io.csr -signkey /etc/ssl/xip.io/xip.io.key -out /etc/ssl/xip.io/xip.io.crt
cat /etc/ssl/xip.io/xip.io.crt /etc/ssl/xip.io/xip.io.key | tee /etc/ssl/xip.io/xip.io.pem
2、
首先得安装OpenSSL软件包openssl,安装了这个软件包之后,我们可以做这些事情:
o Creation of RSA, DH and DSA Key Parameters # 创建密钥 key
o Creation of X.509 Certificates, CSRs and CRLs # 创建证书
o Calculation of Message Digests #
o Encryption and Decryption with Ciphers # 加密、解密
o SSL/TLS Client and Server Tests # SSL 服务器端/客户端测试
o Handling of S/MIME signed or encrypted Mail # 处理签名或加密了的邮件
1、生成RSA密钥的方法
openssl genrsa -des3 -out privkey.pem 2048
这个命令会生成一个2048位的密钥,同时有一个des3方法加密的密码,如果你不想要每次都输入密码,可以改成:
-openssl genrsa -out privkey.pem 2048
建议用2048位密钥,少于此可能会不安全或很快将不安全。
2、生成一个证书请求
-openssl req -new -key privkey.pem -out cert.csr
这个命令将会生成一个证书请求,当然,用到了前面生成的密钥privkey.pem文件
这里将生成一个新的文件cert.csr,即一个证书请求文件,你可以拿着这个文件去数字证书颁发机构(即CA)申请一个数字证书。CA会给你一个新的文件cacert.pem,那才是你的数字证书。
如果是自己做测试,那么证书的申请机构和颁发机构都是自己。就可以用下面这个命令来生成证书:
-openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
这个命令将用上面生成的密钥privkey.pem生成一个数字证书cacert.pem
3、使用数字证书和密钥
有了privkey.pem和cacert.pem文件后就可以在自己的程序中使用了,比如做一个加密通讯的服务器
相关文章推荐
- 源码分析之tinyhttpd-0.1
- thttpd+cgi
- Android HttpClient基本使用方法
- ASIHTTPRequest中的DELETE、PUT、GET、POST请求实例-备用
- tcp短连接场长连接
- springmvc No mapping found for HTTP request with URI 可能原因统计
- TCP端口扫描
- 如何使用Reaver破解Wi-Fi网络的WPA密码
- 华中15邀请赛网络赛
- OkHttp + Gson
- TCP三次握手
- HTTP常见状态码
- Meta http-equiv属性详解
- System.Web.HttpException: 超过了最大请求长度!解决办法[转帖]
- Android系列之网络(三)----使用HttpClient发送HTTP请求(分别通过GET和POST方法发送数据)
- TCP/IP、Http、Socket的区别
- 使用iptraf,ifstat查看网络流量
- Android系列之网络(二)----HTTP请求头与响应头
- Android系列之网络(一)----使用HttpClient发送HTTP请求(通过get方法获取数据)
- HTTP协议详解