如何在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:00" 

2. 生成证书

参考连接:https://www.digitalocean.com/community/tutorials/openssl-essentials-working-with-ssl-certificates-private-keys-and-csrs

Generate a Self-Signed Certificate

Use this method if you want to use HTTPS (HTTP over TLS) to secure your Apache HTTP or Nginx web server, and you do not require that your certificate is signed by a CA.

This command creates a 2048-bit private key (domain.key) and a self-signed certificate (domain.crt) from scratch:

1 openssl req 2        -newkey rsa:2048 -nodes -keyout domain.key 3        -x509 -days 365 -out domain.crt

Answer the CSR information prompt to complete the process.

The -x509 option tells req to create a self-signed cerificate. The -days 365 option specifies that the certificate will be valid for 365 days. A temporary CSR is generated to gather information to associate with the certificate.

生成证书以后,把 domain.key 和 domain.crt 的内容 复制到 cert.pem 中 上面为 private key,下面为 certificate 部分。

3.把系统时间调整到现在的时间。

4.查看证书的开始时间和过期时间是否如你的预期呢?

openssl x509 -startdate -noout -in key.pem

原文地址:https://www.cnblogs.com/qifei-liu/p/9155663.html

时间: 2024-08-06 23:23:38

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

Linux下使用openssl生成证书

利用OpenSSL生成库和命令程序,在生成的命令程序中包括对加/解密算法的测试,openssl程序,ca程序.利用openssl,ca可生成用于C/S模式的证书文件以及CA文件. 证书文件的生成步骤: 一.服务器端1.生成服务器端的私钥(key文件); openssl genrsa -des3 -out server.key 1024 运行时会提示输入密码,此密码用于加密key文件(参数des3是加密算法,也可以选用其他安全的算法),以后每当需读取此文件(通过openssl提供的命令或API)都

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

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

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

linux下使用openssl生成 csr crt CA证书

本文主要借鉴和引用了下面2个地址的内容,然后在自己的机器上进行了测试和执行,并做了如下记录. ref: http://blog.chinaunix.net/uid-26760055-id-3128132.html http://www.111cn.net/sys/linux/61591.htm 创建测试目录 mkdir /tmp/create_key/ca cd /tmp/create_key/ 证书文件生成: 一.服务器端 1.生成服务器端    私钥(key文件); openssl genr

【转】linux下使用openssl生成 csr crt CA证书

创建测试目录 mkdir /tmp/create_key/ca cd /tmp/create_key/ 证书文件生成: 一. 服务器端 1. 生成服务器端 私钥(key文件): openssl genrsa -des3 -out server.key 1024 运行时会提示输入密码,此密码用于加密key文件(参数des3是加密算法,也可以选用其他安全的算法),以后每当需读取此文件(通过openssl提供的命令或API)都需输入口令,如果不要口令,则去除口令: mv server.key serv

openssl生成证书链多级证书

环境centos6.5 初始化 /etc/pki/tls/openssl.cnf rm -rf /etc/pki/CA/*.old touch /etc/pki/CA/index.txt echo 01 > /etc/pki/CA/serial echo 02 > /etc/pki/CA/serial rm -rf keys mkdir keys 生成根CA并自签(Common Name填RootCA) openssl genrsa -des3 -out keys/RootCA.key 204

OPENSSL 生成https 客户端证书

下面说下拿服务器证书.(前提是服务器是https,客户端认证用的时候),服务端不给的时候,我们自己去拿(不给怼他!,哈哈,开个玩笑,都会给的) openssl s_client -connect 域名:端口号 -showcerts|openssl x509 -outform der > cert.der 例如: openssl s_client -connect www.baidu.com:443 -showcerts|openssl x509 -outform der > cert.der

OpenSSL生成公钥私钥

证书标准 X.509 - 这是一种证书标准,主要定义了证书中应该包含哪些内容.其详情可以参考RFC5280,SSL使用的就是这种证书标准. 编码格式 同样的X.509证书,可能有不同的编码格式,目前有以下两种编码格式. PEM - Privacy Enhanced Mail,打开看文本格式,以"-----BEGIN..."开头, "-----END..."结尾,内容是BASE64编码.查看PEM格式证书的信息:openssl x509 -in certificate

再也不用“‘“使用OpenSSL生成证书”了

在百度中搜索“使用OpenSSL生成证书”,百度为您找到相关结果约74,500个,还有这么多人在找免费SSL证书,还用OpenSSL生成自签证书吗? 沃通的在线宣传要加强呀!多少站长众里寻她千百度,多少夜挑灯奋站,只为这张能支持所有浏览器的免费的SSL证书: 沃通免费SSL证书支持所有浏览器.服务器.移动终端,无需注册,10分钟颁发. 下面分享一下经验. 1.首先,移步这里快速申请网址:https://buy.wosign.com/QuickToApplyFreeSSL.html.全中文,不用注