需求:验证过期的证书在系统中不能使用。

问题:如何生成过期的证书呢?

解决方法:1.调整系统时间

2.生成证书

3.验证证书startdate 和 enddate 是否符合你的预期

1.调整系统时间

          1.Set date from the command line:

  date +%Y%m%d -s "" 

          2.Set time from the command line:

  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:

 openssl req \
-newkey rsa: -nodes -keyout domain.key \
-x509 -days -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

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

  1. Linux下使用openssl生成证书

    利用OpenSSL生成库和命令程序,在生成的命令程序中包括对加/解密算法的测试,openssl程序,ca程序.利用openssl,ca可生成用于C/S模式的证书文件以及CA文件. 参考:http:// ...

  2. openssl生成自签名证书

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

  3. 使用openssl生成双向加密证书(转)

    要生成证书的目录下建立几个文件和文件夹,有./demoCA/./demoCA/newcerts/./demoCA/private/./demoCA/index.txt (空文件,生成证书时会将数据记录 ...

  4. java验证openssl生成的ssl证书和私钥是否匹配

    最近有一个需求上传ssl证书和私钥,但是上传之前需要验证ssl证书和私钥是否正确,其中的业务逻辑涉及到以下几点: 一.读取ssl证书,读取ssl证书公钥       要实现该功能比较简单,java里面 ...

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

    证书文件生成:一.服务器端1.生成服务器端    私钥(key文件);openssl genrsa -des3 -out server.key 1024运行时会提示输入密码,此密码用于加密key文件( ...

  6. linux下使用openssl生成https的crt和key证书

    x509证书一般会用到三类文,key,csr,crt Key 是私用密钥openssl格,通常是rsa算法. Csr 是证书请求文件,用于申请证书.在制作csr文件的时,必须使用自己的私钥来签署申,还 ...

  7. 用OpenSSL生成自签名证书在IIS上搭建Https站点(用于iOS的https访问)

    前提: 先安装openssl,安装有两种方式,第一种直接下载安装包,装上就可运行:第二种可以自己下载源码,自己编译.这里推荐第一种. 安装包:http://slproweb.com/products/ ...

  8. OpenSSL使用1(用OpenSSL生成自签名证书在IIS上搭建Https站点)(用于iOS的https访问)

    前提: 先安装openssl,安装有两种方式,第一种直接下载安装包,装上就可运行:第二种可以自己下载源码,自己编译.这里推荐第一种. 安装包:http://slproweb.com/products/ ...

  9. Windows下使用OpenSSL生成自签证书

    下载OpenSSLhttp://slproweb.com/products/Win32OpenSSL.html 生成证书 生成crt证书CMD进入安装bin目录,执行命令:openssl req -x ...

随机推荐

  1. 使用Gulp压缩IMG

    继续说Gulp压缩img 不会安装Gulp的小伙伴们,就去看我的上一篇吧!内容怎么安装的都有! 1.咱们先来安装任务插件吧: npm install gulp-imagemin --save-dev ...

  2. .NET开源工作流RoadFlow-流程运行-菜单配置

    经过流程设计和表单设计后,一个流程就设置完成了,下面说说怎么让设计好的流程运行起来吧. 流程和表单设计完成发布后都在应用程序库里,我们只要将流程在角色应用中配置给相应的用户即可让流程选择了. 在系统管 ...

  3. C++ 输出菱形

    输出*号组成的菱形: // print.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> ...

  4. 【转】python安装库

    1.打开网址https://pypi.python.org/pypi/numpy,找到安装的python版本对应的numpy版本. 我的python版本是 下载的对应numpy版本是 2.将numpy ...

  5. PowerDesigner 连接数据库(以MySQL)为例

  6. App后台开发架构实践笔记

    1 App后台入门 1.1 App后台的功能 (1)远程存储数据: (2)消息中转. 1.2 App后台架构 架构设计的流程 (1) 根据App的设计,梳理出App的业务流程: (2) 把每个业务流程 ...

  7. matlab矩阵

    矩阵的转置用',比如: a = [1,2,3]; b = a'; %b 转置成一个列向量,可以用于矩阵 linspace是Matlab中的一个指令,用于产生指定范围内的指定数量点数,相邻数据跨度相同, ...

  8. dos.ORM配置和使用

    处理oralce,sqlserver,access及其他常用数据库,下载和学习地址 1.web.config配置数据库连接字符串,以及数据库类型: <connectionStrings>& ...

  9. pnp4nagios 性能调优

    http://popozhu.github.io/2014/03/12/pnp4nagios%E7%9A%84%E5%B9%B6%E5%8F%91/ rrd目录分层 bulk模式 修改模板 修改/pr ...

  10. 实验验证stack和heap中是否被设初值

    #include <iostream> #include <stdlib.h> using namespace std; class Foo { public: int i; ...