Cannot connect to Google Cloud SQL using SSL + Golang from Google App Engine

非 Y 不嫁゛ 提交于 2019-12-01 21:29:50

Are you connecting with SSL? This error message indicates that must set the ServerName property when you register your custom TLSConfig with the mysql driver, in addition to specifying the project-id:instance-name inside sql.Open().

e.g. Use the TLS setup from the docs, but add a ServerName in your call to RegisterTLSConfig:

mysql.RegisterTLSConfig("custom", &tls.Config{
            RootCAs:      rootCertPool,
            Certificates: clientCert,
            ServerName:   "projectName:instanceName",
        })

Then append ?tls=nameOfYourCustomTLSConfig

db, err := sql.Open("mysql", "user@cloudsql(project-id:instance-name)/dbname?tls=custom")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!