使用openssl生成ssl(https)证书

openssl生成证书

[[email protected] key]$ pwd
/app/nginx/key

  1. 生成私钥
    openssl genrsa -out server.key 2048
  2. 生成证书请求
    openssl req -new -key server.key -out server.csr
  3. 填入信息
    
    [[email protected] key]$ openssl req -new -key server.key -out server.csr
    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) [XX]:cn
    State or Province Name (full name) []:gd
    Locality Name (eg, city) [Default City]:gz
    Organization Name (eg, company) [Default Company Ltd]:ai
    Organizational Unit Name (eg, section) []:ai
    Common Name (eg, your name or your server‘s hostname) []:112.96.28.206
    Email Address []:

Please enter the following ‘extra‘ attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[[email protected] key]$
[[email protected] key]$ ls
old server.csr server.key

4. 备份一份服务器密钥文件
cp server.key server.key.org
5. 去除文件口令
openssl rsa -in server.key.org -out server.key
6. 生成证书文件server.crt
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

[[email protected] key]$ openssl rsa -in server.key.org -out server.key
writing RSA key
[[email protected] key]$
[[email protected] key]$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=cn/ST=gd/L=gz/O=ai/OU=ai/CN=112.96.28.206
Getting Private key



一般只需三步:
1. openssl genrsa -out server.key 2048
2. openssl req -new -key server.key -out server.csr
3. openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

关于密码:
openssl genrsa -out server.key 2048
    不需要密码。
openssl genrsa -des3 -out server.key 2048
    需要密码。
https://www.jianshu.com/p/9523d888cf77

关于域名:
用openssl,域名可以不输;
用keystore,必须输入。

原文地址:http://blog.51cto.com/170023/2154883

时间: 2024-07-31 23:00:56

使用openssl生成ssl(https)证书的相关文章

使用openssl生成SSL完全参考手册

openssl是一个开放源代码的SSL实现.基于openssl指令的最简单和最主要应用就是使用req.CA和X509来签发一个证书. openssl提供了命令行选项和交互式两种方式来执行各种操作. 在命令行中直接输入openssl可进入交互shell,如下: [[email protected] local]# openssl OpenSSL> help openssl:Error: 'help' is an invalid command. Standard commands asn1pars

let's encrypt生成免费https证书 ubuntu+tomcat+nginx+let's encrypt

1. 下载let's encrypt $ sudo add-apt-repository ppa:certbot/certbot $ sudo apt-get update $ sudo apt-get install certbot 2. 生成密钥,调用之前需要停止nginx certbot certonly --standalone -d www.域名1.com -d www.域名2.com 生成成功,提示如下 IMPORTANT NOTES: - Congratulations! Your

OpenSSl生成SSL证书(支持https)

一:环境与安装说明 WIN7_64,Nginx服务器,OpenSSL_Win64.本人使用phpStudy集成开发环境,使用Nginx+PHP,支持浏览器https请求. nginx下载地址:http://nginx.org/en/download.html      openssl下载地址:http://slproweb.com/products/Win32OpenSSL.html      官网地址:https://www.openssl.org/source/ 二:安装OpenSSL及配置

openssl生成SSL证书的流程

SSL证书通过在客户端浏览器和Web服务器之间建立一条SSL安全通道(Secure socketlayer(SSL),SSL安全协议主要用来提供对用户和服务器的认证:对传送的数据进行加密和隐藏:确保数据在传送中不被改变,即数据的完整性,现已成为该领域中全球化的标准.由于SSL技术已建立到所有主要的浏览器和WEB服务器程序中,因此,仅需安装服务器证书就可以激活该功能了).即通过它可以激活SSL协议,实现数据信息在客户端和服务器之间的加密传输,可以防止数据信息的泄露.保证了双方传递信息的安全性,而且

openssl生成SSL证书的流程 - moonhillcity的博客 - CSDN博客

1.安装openssl 之后在/usr/lib/ssl目录下(ubuntu系统,用whereis查下ssl目录即可)下找到openssl.cnf,拷贝到工作目录下. 2.工作目录下新建demoCA文件夹,文件夹中新建文件index.txt和serial,再创建一个newcerts的文件夹.在serial里面添加字符01. mkdir demoCA cd demoCA touch ./{serial, index.txt} vi serial 添加01 :wq 生成证书过程:(注意以下过程都在工作

SSL/TLS深度解析--OpenSSL 生成自签证书

密钥算法 OpenSSL 支持 RSA.DSA 和 ECDSA 密钥,但是在实际场景中只是用 RSA 和 ECDSA 密钥.例如 Web 服务器的密钥,都使用RSA或ECDSA,因为DSA效率问题会限制在1024位(相对旧版本浏览器不支持更长的DSA密钥),ECDSA还没有全面范围的普及.比如SSH,一般都是使用DSA和RSA,而不是所有的客户端(不只是浏览器)都支持ECDSA算法. 密钥长度 默认的密钥长度一般都不够安全,老版本的 OpenSSL 默认 RSA 私钥是1024位,所以我们需要指

OpenSSL 与 SSL 数字证书概念贴

SSL/TLS 介绍见文章 SSL/TLS原理详解. 如果你想快速自建CA然后签发数字证书,请移步 基于OpenSSL自建CA和颁发SSL证书. 首先简单区分一下HTTPS.SSL.OpenSSL三者的关系: SSL是在客户端和服务器之间建立一条SSL安全通道的安全协议,而OpenSSL是TLS/SSL协议的开源实现,提供开发库和命令行程序.常说的HTTPS是HTTP的加密版,底层使用的加密协议是SSL. 1.PKI.CA与证书 PKI 就是 Public KeyInfrastructure 的

如何在linux系统内用openssl 生成 过期的证书

需求:验证过期的证书在系统中不能使用. 问题:如何生成过期的证书呢? 解决方法:1.调整系统时间 2.生成证书 3.验证证书startdate 和 enddate 是否符合你的预期 1.调整系统时间           1.Set date from the command line:  1 date +%Y%m%d -s "20120418"            2.Set time from the command line:  1 date +%T -s "11:14

openssl生成自签名证书

1.生成x509格式的CA自签名证书 openssl req -new -x509 -keyout ca.key -out ca.crt 2.生成服务端的私钥(key文件)及申请证书文件csr文件 openssl genrsa -des3 -out server.key 1024 openssl req -new -key server.key -out server.csr 3.生成客户端的私钥(key文件)及申请证书csr文件 openssl genrsa -des3 -out client