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 测试

相关推荐
武子康2 小时前
大数据-100 Spark DStream 转换操作全面总结:map、reduceByKey 到 transform 的实战案例
大数据·后端·spark
expect7g3 小时前
Flink KeySelector
大数据·后端·flink
Raymond运维3 小时前
MariaDB源码编译安装(二)
运维·数据库·mariadb
沢田纲吉3 小时前
🗄️ MySQL 表操作全面指南
数据库·后端·mysql
RestCloud19 小时前
SQL Server到Hive:批处理ETL性能提升30%的实战经验
数据库·api
阿里云大数据AI技术19 小时前
StarRocks 助力数禾科技构建实时数仓:从数据孤岛到智能决策
大数据
RestCloud19 小时前
为什么说零代码 ETL 是未来趋势?
数据库·api
ClouGence21 小时前
CloudCanal + Paimon + SelectDB 从 0 到 1 构建实时湖仓
数据库
Lx3521 天前
Hadoop数据处理优化:减少Shuffle阶段的性能损耗
大数据·hadoop
武子康1 天前
大数据-99 Spark Streaming 数据源全面总结:原理、应用 文件流、Socket、RDD队列流
大数据·后端·spark