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

https接口的支持判断,http升级到https需求

https接口的支持判断,http升级到https需求

https接口的支持判断,http升级到https需求

1.以下是仅仅支持http,不支持https的提示。

http://myapi.mytest.com:8081/pinganzong/getCity
{"resCode":"999999","resMsg":"系统异常","data":null}
https://myapi.mytest.com:8081/pinganzong/getCity
ERR_SSL_PROTOCOL_ERRORhttp://myapi.mytest.com:8888/HRM3_WEB_AOTU/AotuPA/addorder
HTTP Status 500 -https://myapi.mytest.com:8888/HRM3_WEB_AOTU/AotuPA/addorder
ERR_SSL_PROTOCOL_ERROR

2.如果是仅仅支持https(需要配置ssl证书),不支持http,则在请求http接口的时候,会返回:

400 Bad Request
The plain HTTP request was sent to HTTPS port
stgw
这个报错信息。

3.postman请求:https接口可以在浏览器上面直接访问。

https请求demo:
https://apis.map.qq.com/ws/district/v1/list?key=XXXX

4.测试过程:推断https不支持。

# 强制使用TLS 1.2
curl -X POST -H "Content-Type: application/json" -d '{"sign":"hah"}' "https://myapi.mytest.com:8081/public/pinganzong/getCity" --tlsv1.2# 或者尝试TLS 1.1
curl -X POST -H "Content-Type: application/json" -d '{"sign":"hah"}' "https://myapi.mytest.com:8081/public/pinganzong/getCity" --tlsv1.1# 启用详细日志查看SSL握手过程
curl -X POST -H "Content-Type: application/json" -d '{"sign":"hah"}' "https://myapi.mytest.com:8081/public/pinganzong/getCity" -v# 测试HTTP连接(如果支持)
curl -X POST -H "Content-Type: application/json" -d '{"sign":"hah"}' "http://myapi.mytest.com:8081/public/pinganzong/getCity"# 使用wget测试
wget --no-check-certificate -O- "https://myapi.mytest.com:8081/public/pinganzong/getCity"[root@VM-1-84-centos /]$curl -X POST -H "Content-Type: application/json" -d '{"sign":"hah"}' "https://myapi.mytest.com:8081/public/pinganzong/getCity" --tlsv1.2
curl: (35) SSL received a record that exceeded the maximum permissible length.
[root@VM-1-84-centos /]$curl -X POST -H "Content-Type: application/json" -d '{"sign":"hah"}' "https://myapi.mytest.com:8081/public/pinganzong/getCity" --tlsv1.1
curl: (35) SSL received a record that exceeded the maximum permissible length.
[root@VM-1-84-centos /]$
[root@VM-1-84-centos /]$curl -X POST -H "Content-Type: application/json" -d '{"sign":"hah"}' "https://myapi.mytest.com:8081/public/pinganzong/getCity" -v
* About to connect() to myapi.mytest.com port 8081 (#0)
*   Trying 175.XX.192.XX...
* Connected to myapi.mytest.com (175.XX.192.XX) port 8081 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crtCApath: none
* NSS error -12263 (SSL_ERROR_RX_RECORD_TOO_LONG)
* SSL received a record that exceeded the maximum permissible length.
* Closing connection 0
curl: (35) SSL received a record that exceeded the maximum permissible length.[root@VM-1-84-centos /]$curl -X POST -H "Content-Type: application/json" -d '{"sign":"hah"}' "http://myapi.mytest.com:8081/public/pinganzong/getCity"
{"resCode":"-1","resMsg":"签名有误"}[root@VM-1-84-centos /]$
[root@VM-1-84-centos /]$
[root@VM-1-84-centos /]$wget --no-check-certificate -O- "https://myapi.mytest.com:8081/public/pinganzong/getCity"
--2025-10-28 15:15:15--  https://myapi.mytest.com:8081/public/pinganzong/getCity
Resolving myapi.mytest.com (myapi.mytest.com)... 175.XX.192.XX
Connecting to myapi.mytest.com (myapi.mytest.com)|175.XX.192.XX|:8081... connected.
OpenSSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Unable to establish SSL connection.

5.配置demo

server {listen 443 ssl;server_name yourdomain.com;ssl_certificate /path/to/your/certificate.pem;ssl_certificate_key /path/to/your/private.key;ssl_session_timeout 5m;ssl_protocols TLSv1.2;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;ssl_prefer_server_ciphers on;# 其他配置...
}

6.获取SSL证书‌
SSL证书是配置HTTPS的基础,主要有以下类型:

DV证书‌:适合个人站点,仅验证域名所有权
OV证书‌:适合企业官网,需要验证企业资质
EV证书‌:适合电商、金融等对安全要求更高的网站

可以从云服务商(如阿里云、腾讯云)申请免费或付费证书,免费证书通常有效期为3个月


7.完整迁移流程‌
1.申请并安装证书‌:选择合适的证书类型并部署到服务器
2.配置301重定向‌:确保所有HTTP流量永久重定向到HTTPS
3.更新内部链接‌:将网站中所有硬编码的HTTP链接改为HTTPS
4.提交搜索引擎更新‌:在Google Search Console、百度站长平台中更新网站属性

 

更新外部链接:需要提前通知第三方,最好可以同时支持http和https两种方式,如果不能支持,则需要约定时间,同步来升级到https来访问。

http://www.jsqmd.com/news/26542/

相关文章:

  • 源杰科技国产激光器芯片-光模块源头
  • 2025 年仿石漆厂家最新推荐榜,技术实力与市场口碑深度解析的优质企业精选批刮 / 别墅 / 批发 / 出口仿石漆推荐
  • 2025 年外墙涂料厂家最新推荐榜,技术实力与市场口碑深度解析外墙涂料工程 / 外墙涂料翻新推荐
  • 2025 年 10 月不锈钢厂家推荐排行榜,301不锈钢,316L不锈钢,304不锈钢,420不锈钢,201不锈钢,不锈钢材料公司推荐
  • 2025 年 10 月废水蒸发器厂家权威推荐榜:MVR/薄膜刮板/单效/双效/三效/多效/高盐/含盐/降膜/结晶/mvr母液/氯化钠/硫酸铵/垃圾渗滤液/化工废水刮板/强制循环/废水脱盐蒸发器厂家精选
  • 2025 年 10 月搅拌机厂家推荐排行榜,立式搅拌机,潜水搅拌机,双曲面搅拌机,桨式/框式/反应/电动/侧入式/水处理/加药搅拌机公司精选
  • 2025 年 10 月真空炉厂家推荐排行榜,真空热处理炉,真空回火炉,真空退火炉,真空时效炉,气淬炉,烧结炉,铜钨合金真空焊接炉公司推荐
  • 2025 年 10 月通风管道厂家推荐排行榜,螺旋风管,不锈钢风管,镀锌板排烟风管,厨房酒店排烟风管,消音风管,共板法兰风管公司精选
  • 2025年小型混凝土抹光机厂家权威推荐榜单:抹光机/小型抹光机 /大型抹光机源头厂家精选
  • 2025年靠谱的钛棒厂家最新TOP实力排行
  • 2024ICPC南京VP记录
  • 2025年比较好的木质门不锈钢合页厂家最新实力排行
  • 使用Spring AI流式调用DeepSeek
  • 2025年天津自动化展公司权威推荐榜单:泵阀展/铸造与压铸展 /焊接与切割展源头公司精选
  • 不用ffmpeg如何将多个图片转换为视频
  • 2025年热门的泗水面粉机厂家最新用户好评榜
  • 读书笔记摘抄:恋爱
  • 2025 年除磷剂厂家最新推荐榜,技术实力与市场口碑深度解析,高效环保品牌选购指南铁盐除磷剂/液体除磷剂/固体除磷剂公司推荐
  • 为什么不要轻易使用SELECT *?
  • 大模型结构化输出json, 最新方法更方便
  • 2025 年醋酸钠厂家最新推荐榜,覆盖无水 / 三水 / 液体多类型,技术实力与市场口碑深度解析液体醋酸钠/碳源醋酸钠/结晶醋酸钠/工业醋酸钠公司推荐
  • 2025年比较好的智能触摸一体机厂家推荐及采购指南
  • 2025 年自动抛光机厂家最新推荐榜,聚焦企业技术实力与市场口碑深度解析水龙头/门执手/锌合金/铝合金自动抛光机/打磨机器人抛光去毛刺公司推荐
  • 2025 年地膜厂家最新推荐榜,聚焦企业综合实力与市场口碑深度解析降解地膜/银色地膜/双色地膜/全生物降解地膜/银黑双面地膜公司推荐
  • 2025年知名的高压无功补偿柜最新TOP厂家排名
  • docker /overlay2/xxx/merged 爆满
  • 2025 年打磨机器人厂家最新推荐榜,技术实力与市场口碑深度解析,涵盖多领域适配方案摩托车配件打磨机器人/汽车配件打磨机器人公司推荐
  • 机器学习之Boosting算法
  • 2025年热门的高定衣柜灯厂家推荐及选择指南
  • 完整教程:C语言自学--自定义类型:联合和枚举