openssl req 证书请求及自签名证书
介绍
openssl req 用于生成证书请求,以让第三方权威机构CA来签发,生成我们需要的证书。req 命令也可以调用x509命令,以进行格式转换及显示证书文件中的text,modulus等信息。如果你还没有密钥对,req命令可以一统帮你生成密钥对和证书请求,也可以指定是否对私钥文件进行加密。
语法
openssl req[-inform PEM|DER] [-outform PEM|DER] [-in filename] [-passin arg] [-out filename] [-passout arg] [-text] [-pubkey] [-noout] [-verify] [-modulus] [-new] [-rand file(s)] [-newkey rsa:bits] [-newkey alg:file] [-nodes] [-key filename] [-keyform PEM|DER] [-keyout filename] [-keygen_engine id] [-[digest]] [-config filename] [-subj arg] [-multivalue-rdn] [-x509] [-days n] [-set_serial n] [-asn1-kludge] [-no-asn1-kludge] [-newhdr] [-extensions section] [-reqexts section] [-utf8] [-nameopt] [-reqopt] [-subject] [-subj arg] [-batch] [-verbose] [-engine id]
-new
这个选项用于生成一个新的证书请求,并提示用户输入个人信息。如果没有指定-key 则会先生成一个私钥文件,再生成证书请求。
- E:\OpenSSL\foo>openssl req -new -key rsa_pri_nopw.pem -out crs.pem
- Loading 'screen' into random state - done
- 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) [AU]:CN
- State or Province Name (full name) [Some-State]:HeBei
- Locality Name (eg, city) []:SJZ
- Organization Name (eg, company) [Internet Widgits Pty Ltd]:CCIT
- Organizational Unit Name (eg, section) []:CCIT
- Common Name (eg, YOUR name) []:fym
- Email Address []:fym0121@163.com
- Please enter the following 'extra' attributes
- to be sent with your certificate request
- A challenge password []:
- An optional company name []:
- E:\OpenSSL\foo>ls
- crs.pem
- rsa_pri_nopw.pem
没有指定-key选项时,会生成私钥文件,默认是有密码保护的,-nodes(no des),可以明确指定不需要密码保护。-keyout可以指定生成的私钥文件名,-pubout可以指定生成的公钥文件名
- openssl req -new -out crs.pem
- openssl req -new -out crs.pem -nodes
-subj 替换或指定证书申请者的个人信息
格式是:/type0=value0/type1=value1/type2=...(其中C是Country,ST是state,L是local,O是Organization,OU是Organization Unit,CN是common name)
- E:\OpenSSL\foo>openssl req -new -key rsa_pri_nopw.pem -out crs.pem -subj /C=CN/S
- T=HB/L=SJZ/O=CCIT/OU=CCIT/CN=fym/emailAddress=fym0121@163.com
- Loading 'screen' into random state - done
-newkey arg 生成私钥和证书请求,类似与-new
arg的格式是rsa:nbit ,还有几个格式,我只能看懂这个
- openssl req -newkey rsa:1024 -out crs.pem
-xf09 生成自签名证书
- openssl req -newkey rsa:1024 -x509 -nodes -out selfsing.pem
-config 指定配置文件,参见config
产生自签名的root CA
1、建立目录结构(参加ca directory structure)
假设当前工作目录为E:\OpenSSL\foo,在此目录下建立以下目录结构
- E:\OpenSSL\foo>mkdir demoCA
- E:\OpenSSL\foo>mkdir demoCA\private demoCA\newcerts
在demoCA目录下建立两个空文件,serial和index.txt,并向serial文件中写入"01"两个字符
2、产生自签名证书,作为root ca使用
- E:\OpenSSL\foo>openssl req -new -x509 -keyout cakey.pem -out cacert.pem
提示输入密码保护私钥,和自签名root ca的信息。生成两个文件,将cakey.pem放到demoCA\private目录下,将cacert.pem放到demoCA目录下。
- E:\OpenSSL\foo>move cacert.pem demoCA
- E:\OpenSSL\foo>move cakey.pem demoCA\private
至此,root ca已经建立完毕。
证书请求及签名
1、生成请求
- E:\OpenSSL\foo>openssl req -new -nodes -out req.pem
提示输入个人信息,最后生成req.pem证书请求文件。
2、签名,生成证书
- E:\OpenSSL\foo>openssl ca -in req.pem -out newcert.pem
- Using configuration from e:\OpenSSL\bin\openssl.cfg
- Loading 'screen' into random state - done
- Enter pass phrase for ./demoCA/private/cakey.pem:
- Check that the request matches the signature
- Signature ok
openssl req 证书请求及自签名证书的更多相关文章
- openssl 证书请求和自签名命令req详解
1.密钥.证书请求.证书概要说明 在证书申请签发过程中,客户端涉及到密钥.证书请求.证书这几个概念,初学者可能会搞不清楚三者的关系,网上有的根据后缀名来区分三者,更让人一头雾水.我们以申请证书的流程说 ...
- (11) openssl req(生成请求证书、私钥和自建CA)
伪命令req大致有3个功能:生成证书请求文件.验证证书请求文件和创建根CA. 由于openssl req命令选项较多,所以先各举几个例子,再集中给出openssl req的选项说明.若已熟悉opens ...
- [https][openssl] OpenSSL 公钥、私钥以及自签名证书
转自:https://www.zybuluo.com/muyanfeixiang/note/392079 简介 公钥私钥用来互相加解密的一对密钥,一般是采用RSA非对称算法.公钥加密的私钥能解密,私钥 ...
- 解决linux netcore https请求使用自签名证书忽略安全检查方法
当前系统环境:centos7 x64. dotnet 2.0. 不管是 ServicePointManager.ServerCertificateValidationCallback = (a, b, ...
- ubuntu google chrome 忽略证书错误 -- 解决自签名证书不支持的问题
ubuntu chrome 打开自签名的证书的服务器的https时,提示 Your connection is not private. 错误代码:NET::ERR_CERT_AUTHORITY_IN ...
- 8.openssl req
数字证书申请和生成工具.也可以为根CA自行签署证书. 该命令中很多值.属性.格式或默认值都在config文件openssl.cnf中指定. [root@xuexi ~]# man req NAME r ...
- (转)openssl 命令: openssl req 命令详解
openssl req命令主要的功能有,生成证书请求文件, 查看验证证书请求文件,还有就是生成自签名证书.本文就主要记录一下open ...
- openssl req(生成证书请求和自建CA)
伪命令req大致有3个功能:生成证书请求文件.验证证书请求文件和创建根CA.由于openssl req命令选项较多,所以先各举几个例子,再集中给出openssl req的选项说明.若已熟悉openss ...
- openssl req(生成证书请求和自建CA)(转)
openssl req(生成证书请求和自建CA) 伪命令req大致有3个功能:生成证书请求文件.验证证书请求文件和创建根CA.由于openssl req命令选项较多,所以先各举几个例子,再集中 ...
随机推荐
- Laravel学习笔记之Session源码解析(下)
说明:在中篇中学习了session的CRUD增删改查操作,本篇主要学习关闭session的相关源码.实际上,在Laravel5.3中关闭session主要包括两个过程:保存当前URL到session介 ...
- centos6安装ElasticSearch5.6.5错误记录
在centos6安装ES的时候遇到不少问题.这里记录日志.以后安装一定要升级centos7,别说啥稳定问题了,该升级就升级. [1]: max file descriptors [4096] for ...
- (算法)等概率选出m个整数
题目: 从大小为n的整数数组A中随机选出m个整数,要求每个元素被选中的概率相同. 思路: n选m,等概率情况下,每个数被选中的概率为m/n. 方法: 初始化:从A中选择前m个元素作为初始数组: 随机选 ...
- ecshop中smarty最常用的6大基本语法
模板制作比较核心的其实就是变量的使用,因为这些就是数据的根本,想从数据库里获取数据并显示在界面就必须使用smarty来展示,下面是关于smarty的介绍和使用.Smarty是一个php模板引擎,它分开 ...
- Android 分析 Android 应用结构
本文说明 Android 项目组成,虽然简单,但决不能忽视. 当你从简单 Hello World 程序,到会实现一些常见功能,比如,下拉(上拉)刷新最新(加载更多),消息处理(UI 通知更新),Vie ...
- eclipse maven scm
http://my.oschina.net/OutOfMemory/blog/178512 1.安装eclipse的maven插件 m2e(http://wiki.eclipse.org/M2E_u ...
- 单例模式在生产环境jedis集群中的应用
背景:不久前单位上线一款应用,上了生产环境之后,没过多久,便吃掉了服务器所有的内存,最后导致网站服务挂了. 在解决了这一问题之后,我发现这其实是典型的一单例模式,现分享一下. 之前存在问题的老代码如下 ...
- C++ 第十一课 标准c内存函数
calloc() 分配一个二维储存空间 free() 释放已分配空间 malloc() 分配空间 realloc() 改变已分配空间的大小 calloc 语法: #include <st ...
- ajax 二级联动与springmvc 交互
html 测试可以使用 <div class="pageButton" style="height: 60px;margin: 10px;line-height: ...
- WEB打印控件Lodop使用体会
控件的使用方法,作者都已经有详细的使用说明供使用者参考. 但是对于打印表格,确实出现一点小问题,如果表格是自然高度,也就是只设置了table的高度,此时是可以正常显示的 ...