当前位置: 首页 > news >正文

使用openssl生成自签名证书

使用openssl生成自签名证书

  • 1. 交互式生成
  • 2. 一步生成
  • 参考

1. 交互式生成

自签名 SSL 证书的生成涉及一个简单的 3 步过程:

步骤 1:创建服务器私钥

openssl genrsa -out cert.key 2048

步骤 2:创建证书签名请求 (CSR)

openssl req -new -key cert.key -out cert.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) [AU]:CN
State or Province Name (full name) [Some-State]:BJ
Locality Name (eg, city) []:BJ
Organization Name (eg, company) [Internet Widgits Pty Ltd]:TM
Organizational Unit Name (eg, section) []:TM
Common Name (e.g. server FQDN or YOUR name) []:tm.com
Email Address []:Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

步骤 3:使用私钥和 CSR 签署证书

openssl x509 -req -days 3650 -in cert.csr -signkey cert.key -out cert.crt
Certificate request self-signature ok
subject=C=CN, ST=BJ, L=BJ, O=TM, OU=TM, CN=tm.com

恭喜!您现在拥有有效期为 10 年的自签名 SSL 证书。

2. 一步生成

openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \-subj "/C=CN/ST=BJ/L=BJ/O=TM/OU=TM/CN=tm.com" \-keyout cert.key -out cert.crt

参考

Generation of a Self Signed Certificate

http://www.lryc.cn/news/349506.html

相关文章:

  • 【java】泛型
  • 计算思维的理解
  • Python中tkinter编程入门4
  • Milvus的系统架构
  • MFC中关于CMutex类的学习
  • 删除表空间
  • 下载element-ui报错
  • [原创](Modern C++)现代C++的std::bind花式绑定,使用方式大全.
  • Unity射击游戏开发教程:(13)如何在Unity中播放音效
  • Swift—手写防抖、手写图片预加载与多张图片拼接
  • Redis过期键删除策略
  • 413 Request Entity Too Large
  • 工业无风扇计算机的优点
  • 个人学习计划
  • 【电控实物-LK电机】
  • 《Mybatis》系列文章目录
  • ARM机密计算组件
  • Linux 生态与工具
  • RHCE网络服务配置之循环执行的例行性工作
  • vue3使用el-radio-group获取表格数据无法选中问题
  • java并发
  • Python Selenium Grid 环境快速搭建
  • 电机控制系列模块解析(21)—— 弱磁控制
  • 【3dmax笔记】022:文件合并、导入、导出
  • 8、QT——QLabel使用小记2
  • python实现读取串口数据-使用LibModbus库实现一个实时读取串口数据
  • 类与面向对象编程(Object-Oriented Programming, OOP)
  • 引用数据类型 栈内存 堆内存
  • 【class8】人工智能初步(图像识别-----卷积神经网络)
  • Node.js安装及环境配置(超详细!保姆级!!)