TDengine taosAdapter启用HTTPS

HTTPS (Hypertext Transfer Protocol Secure ),是以安全为目标的 HTTP 通道,在HTTP的基础上通过传输加密和身份认证保证了传输过程的安全性 。HTTPS 在HTTP 的基础下加入SSL,HTTPS 的安全基础是 SSL,因此加密的详细内容就需要 SSL。 HTTPS 存在不同于 HTTP 的默认端口及一个加密/身份验证层(在 HTTP与 TCP 之间)。

TDengine 3.x 开始支持 HTTPS,配置步骤如下:

:

    • [1. 生成自签名](#1. 生成自签名)
    • [2. 修改taosadapter配置](#2. 修改taosadapter配置)
    • [3. 测试](#3. 测试)
      • [curl 测试](#curl 测试)
      • 浏览器测试
      • [openssl 测试](#openssl 测试)

1. 生成自签名

自己测试用 OpenSSL 生成 SSL 证书即可。

bash 复制代码
## 生成私钥
[root@c3-65 taos]# openssl  genrsa  -out server.pem 2048
Generating RSA private key, 2048 bit long modulus
................+++
.................................+++
e is 65537 (0x10001)

## 生成签名
[root@c3-65 taos]# openssl req -new -key server.pem  -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) [XX]:CN
State or Province Name (full name) []:BJ
Locality Name (eg, city) [Default City]:BJ
Organization Name (eg, company) [Default Company Ltd]:Taosdata
Organizational Unit Name (eg, section) []:Adapter
Common Name (eg, your name or your server's hostname) []:
Email Address []:

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

## 创建SSL证书
[root@c3-65 taos]#  openssl x509 -req -days 3650 -in cert.csr -signkey server.pem  -out cert.crt
Signature ok
subject=/C=CN/ST=BJ/L=BJ/O=Taosdata/OU=Adapter
Getting Private key

2. 修改taosadapter配置

bash 复制代码
[ssl]
enable = true
certFile = "/etc/taos/cert.crt"
keyFile = "/etc/taos/server.pem"

重启taosAdapter

bash 复制代码
systemctl restart taosadapter

3. 测试

curl 测试

bash 复制代码
[root@c3-65 ~]# curl -uroot:taosdata 127.0.0.1:6041/rest/sql -d "select server_version()"
Client sent an HTTP request to an HTTPS server.

[root@c3-65 ~]# curl -k --insecure -uroot:taosdata https://127.0.0.1:6041/rest/sql -d "select server_version()"
{"code":0,"column_meta":[["server_version()","VARCHAR",7]],"data":[["3.2.3.3"]],"rows":1}[root@c3-65 ~]# 

浏览器测试

openssl 测试

相关推荐
厦门德仔8 分钟前
【YiFeiWebApi】易飞ERP与WMS系统接口对接实战:从0到1全流程指南
大数据·数据库
Neighbor_OldY10 分钟前
线上服务CPU飙高接口超时应急处置实战:从load爆表到快速定位根因,一次线上救火全记录
大数据·运维
内存漫游11 分钟前
Page 到底是什么:数据库如何把一条条记录放进磁盘
数据库
小镇敲码人11 分钟前
【深入浅出】之Qt 事件系统实战:鼠标、键盘、滚轮、窗口与定时器事件
数据库·qt·网络协议·mysql·http
大大大大晴天️12 分钟前
大数据上 K8s 的三种运行范式:离线计算、实时流处理与分析服务
大数据·kubernetes
Sirens.15 分钟前
MySQL数据库:索引
数据库·mysql
2601_9620725017 分钟前
大数据-234 离线数仓 - 异构数据源 DataX 将数据 从 HDFS 到 MySQL
大数据·mysql·hdfs
treacle田1 小时前
达梦数据库-Linux DM主备集群动态增加节点-记录总结
linux·运维·数据库·达梦主备集群动态扩展
一只专注api接口开发的技术猿1 小时前
Open Claw 实战|快速搭建电商商品监控与数据分析能力
大数据·数据库·数据挖掘·数据分析
杨云龙UP1 小时前
Oracle 19c RMAN历史备份清理失败:CONTROL_FILE_RECORD_KEEP_TIME 问题排查与整改实战
linux·运维·网络·数据库·oracle·rac