You need to enable JavaScript to run this app. Google Apps Script开启SSL连接MariaDB 10.4失败排查求助
优惠活动
大模型
产品
解决方案
定价
更多

Google Apps Script开启SSL连接MariaDB 10.4失败排查求助

Google Apps Script 连接SSL配置的MariaDB实例故障记录

基础背景

  • 本次调试使用的参考GAS代码为公开gist项目,调试参数均参考代码示例配置
  • 待连接的MariaDB实例基于Docker Hub官方镜像mariadb:10.4搭建
  • 服务端SSL配置有效性已验证:经Metabase连接测试,服务端状态返回havessl='YES',SSL配置已正常生效

SSL证书生成操作流程

所有SSL密钥与证书均通过openssl命令生成,操作步骤如下:

服务端侧证书生成

  1. 生成CA证书密钥
    openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 > ./ca-key.pem
  2. 生成CA根证书
    openssl req -new -x509 -nodes -days 36500 -key ./ca-key.pem -out ./ca-cert.pem -subj "/C=US/ST=NY/L=NTC/O=company/CN=company"
  3. 创建SQL服务端密钥
    openssl req -newkey rsa:4096 -nodes -keyout ./server-key.pem -out ./server-req.pem -subj "/C=US/ST=NY/L=NTC/O=company/CN=sql.server.com"
  4. 签发SQL服务端证书
    openssl x509 -req -in ./kn-req.pem -days 36500 -CA ./ca-cert.pem -CAkey ./ca-key.pem -CAcreateserial -out ./server-cert.pem
  5. 转换服务端密钥为RSA格式(MariaDB仅可读取该格式的密钥文件)
    openssl rsa -in ./server-key.pem -out ./server-key-rsa.pem

当前SQL服务端已加载ca-cert.pem、server-cert.pem、server-key-rsa.pem三个证书文件,完成SSL运行配置

客户端侧证书生成

  1. 创建客户端连接用密钥
    openssl req -newkey rsa:4096 -nodes -keyout ./client-key.pem -out ./client-req.pem -subj "/C=US/ST=NY/L=NTC/O=company/CN=supermetrics"
  2. 签发客户端证书
    openssl x509 -req -in ./client-req.pem -days 36500 -CA ./ca-cert.pem -CAkey ./ca-key.pem -CAcreateserial -out ./client-cert.pem
  3. 转换客户端密钥为RSA格式
    openssl rsa -in ./client-key.pem -out ./client-key-rsa.pem

调试现状

  • 已通过cat命令导出ca-cert.pem、client-cert.pem、client-key.pem三个文件的内容,逐行复制粘贴到Google Apps Script代码中,并在每一行末尾补充转义标记\n\
  • 开启SSL参数连接时的报错信息:Exception: Failed to establish a database connection. Check connection string, username and password.
  • 交叉验证结论:若移除连接串中的?useSSL=true参数,数据库连接可正常建立
  • 已查阅Google开发论坛、StackOverflow的相关公开资料,现有公开方案描述的GAS连接带SSL的MariaDB配置流程,与当前操作完全一致,但SSL模式下仍无法连通,需定位遗漏的配置项,获取可复现的解决方案

内容的提问来源于stack exchange,提问作者alderson59

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.30 01:24:08