首页 > 其他分享 >mqtt启用ssl参考(2)

mqtt启用ssl参考(2)

时间:2023-04-02 14:45:52浏览次数:41  
标签:file Name certificate 启用 name ssl mqtt key out

1.We first need to install OpenSSL in order to create our certificates and keys. Click here for GitHub or here for the exe.

2.Create CA key pair: Navigate to the Windows start and search OpenSSL. Hit enter on "OpenSSL Command Promt". Make sure you run the following commands as administrator.

openssl genrsa -des3 -out ca.key 2048

 genrsa: generates a RSA private key

des3: Using DES3 cipher for the key generation

out: specifies the output file name (.key)

2048: number of bits for the private key

Your output should look like this:

C:\Users\schue>openssl genrsa -des3 -out ca.key 2048
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:

C:\Users\schue>
  • Enter any password. But remember it, we will need it in a moment again.

  • The pass phrase is used to protect the private key. The generated private file ca.key has both the private and public key.

3.Create CA certificate: Next we are creating a certificate for the CA, using the key pair created in the step before:

openssl req -new -x509 -days 1826 -key ca.key -out ca.crt

 req: certificate request and certification utility

new: generate new certificate, it will prompt user for several input fields

x509: create a self signed certificate

days: specify the number of days the certificate is valid

key: key file with private key to be used for signing

out: specifies the file name for the certificate (.crt)

You should get something like this:

C:\Users\schue>openssl req -new -x509 -days 3650 -key ca.key -out ca.crt
Enter pass phrase for ca.key:
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]:DE
State or Province Name (full name) [Some-State]:Bavaria
Locality Name (eg, city) []:Munich
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Uni
Organizational Unit Name (eg, section) []:Master
Common Name (e.g. server FQDN or YOUR name) []:schue
Email Address []:.

C:\Users\schue>

 As Common Name use your user name like "schue" in my case.

4.Create broker key pair: Next, we are creating a private key for the server with:

openssl genrsa -out server.pem 2048

 genrsa: generate a RSA private key

out: specifies the output file name (.pem)

2048: number of bits for the private key

5.Create certificate request from CA: That key needs to be certified, so we create a certificate request for it, and the certificate needs to be signed by the CA:

openssl req -new -out server.csr -key server.pem

 req: certificate request and certification utility

new: create new request file file

out: file name for the certificate signing request (.csr)

key: file name of the key to be certified

Your output should look like this:

C:\Users\schue>openssl req -new -out server.csr -key server.pem
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]:DE
State or Province Name (full name) [Some-State]:Bavaria
Locality Name (eg, city) []:Munich
Organization Name (eg, company) [Internet Widgits Pty Ltd]:UniMuni
Organizational Unit Name (eg, section) []:EL
Common Name (e.g. server FQDN or YOUR name) []:schue
Email Address []:.

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:0815
An optional company name []:IT

C:\Users\schue>

 6.Verify and sign the certificate request: The last step with OpenSSL is to sign the server request through the CA to get the broker certificate:

openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out cert.der -days 360

 x509: certificate display and signing utility

req: a certificate request is expected as input

in: input file for the certificate

CA: specifies the file to be signed

CAkey: CA private key to sign the certificate with

Cacreateserial: the serial number file gets created if it does not exist

out: output file name

days: how long the certificate shall be valid

7.Convert your .pem file to .der file:

openssl rsa -inform pem -in server.pem -outform der -out key.der

 

原文链接 https://dev.to/bassparanoya/esp32-micropython-mqtt-tls-28fd

下篇介绍上述过程改进及micropython端实现

 

标签:file,Name,certificate,启用,name,ssl,mqtt,key,out
From: https://www.cnblogs.com/timseng/p/17280446.html

相关文章

  • emqtt使用Let's Encrypt配置mqtt开启ssl的问题(1)
    emqtt的wss直接在nginx这一层配置就好。配置mqtts的时候有点问题:原过程1.使用cerbot生成了证书:  2.挂载到emqtt容器  这里参考了一些资料:    后果是一直连接不上  然后就找原因:1)官方的常见问题:......
  • Lixnu:如何安装、启用、访问云服务器中的MySQL数据库?
    Linux系统:CentOS7MySQL版本:5.7.41安装方法:rpm安装(需要自己解决依赖问题)云服务器:阿里云MySQL客户端:Navicat  1、准备工作:软件配置本机是否有mysql软件:rpm-qa|grepmysql是否有冲突软件mariadb:rpm-qa|grepmariadb(如果有)卸载......
  • ffmpeg分辨率更改和无损压缩转码(h264 h265 lossless)
    测试的版本ffmpeg-versionffmpegversionn6.0Copyright(c)2000-2023theFFmpegdevelopersbuiltwithgcc11(Ubuntu11.3.0-1ubuntu1~22.04)configuration:--toolchain=hardened--libdir=/usr/lib/x86_64-linux-gnu--incdir=/usr/include/x86_64-linux-gnu--arch=amd......
  • c# mqtt高性能服务器端源代码 开源框架包括服务器和客户端,支持mqtt3.0及5.0
    c#mqtt高性能服务器端源代码。你还在使用第三方服务软件吗?不如试试这个开发框架,助你一臂之力,无限制,无全开源,无版权约束,全是自主开发。开源框架包括服务器和客户端,支持mqtt3.0及5.0。可嵌入到自己的服务系统及软件客户端中,不受第三方约束。你要问我稳定性如何?我能回答的是已经......
  • 生成ssl证书
    生产证书步骤参考地址1:https://www.cnblogs.com/luxiaoyao/p/10034009.html#:~:text=windows%E4%B8%8B%E7%94%A8nginx%E9%85%8D%E7%BD%AEhttps%E6%9C%8D%E5%8A%A1%E5%99%A8%201%201.%E5%AE%89%E8%A3%85nginx%20%E5%85%88%E5%88%B0%20nginx%20%E5%AE%98%E7%BD%91%E4%B8%8B%E5%9C%......
  • MQTT(EMQX) - Linux CentOS Docker 安装
    MQTT(EMQX)-LinuxCentOS直接安装和Docker安装常规安装下载文件版本选择:https://www.emqx.com/zh/downloads/broker/文本下载:https://www.emqx.com/zh/downloads......
  • O2OA基于nginx的SSL跳转、转发配置---靳宇灵
    1.申请ssl证书,可参考 系统安全-启用HTTPS(腾讯云版) ,如需其他产商的证书可网络上搜索一下,这里不做过多赘述;2.确认服务器上已安装nginx,并可以正常访问。3.新建一个目录(这......
  • 前端用crypto-js来进行加密,php使用openssl_encrypt来进行解密
    项目有个需求,需要对前端提交的密码进行加密传输,防止请求被拦截导致密码的泄露。1、考虑到性能问题,不好太过的占用浏览器资源,我就直接采用了对称加密的方式(aes)来进行处理;2......
  • 如何使用 CAA 记录防止错误签发 SSL 证书?
    什么是CAA?CAA(CertificationAuthorityAuthorization,证书颁发机构授权)是一项降低SSL证书错误颁发的控制措施,由互联网工程任务组(IETF)批准列为IETFRFC6844规范。2017......
  • TLS/SSL工作原理及握手过程
    一、TLS/SSL基础概念1、概念TLS传输层安全性协议(TransportLayerSecurity)SSL安全套接层(SecureSocketsLayer)目的:为互联网通信提供安全以及数据完整性保障。HTTPS=......