使用 SSL 的 PHP 到 MySQL Amazon RDS,确认 SSL
我发现很多关于使用 MYSQL_CLIENT_SSL 标志与 mysql_connect() 调用、与设置和 SSH 隧道相冲突的信息... MYSQL_CLIENT_SSL 可以接受吗?官方文档似乎表明是的,但是堆栈和其他地方的很多帖子都说隧道更好,但没有解释。
如果我使用 MYSQL_CLIENT_SSL,如何验证我是否确实获得了加密连接?我已将它添加到我的 mysql_connect() 调用中,并且它不会抛出任何错误,我认为它正在工作,但我如何确定?
I'm finding lots of conflicting information regarding usage of the MYSQL_CLIENT_SSL flag with a mysql_connect() call, vs setting up and SSH tunnel... Is MYSQL_CLIENT_SSL acceptable? the official documentation seems to indicate yes, but lots of posts on stack and elsewhere say that a tunnel is better but don't explain.
How can I verify that I'm actually getting an encrypted connection if I use MYSQL_CLIENT_SSL? I have added it to my mysql_connect() call and it doesn't throw any errors, I assume it's working, but how can I be sure?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下命令进行检查:
输出应如下所示
You can check it using this:
The output should look like this
我知道这是一个老问题,但我也遇到了这个问题并解决了它,所以我想我会为后代分享我的答案。
Amazon 的文档非常有帮助。首先,您需要从 Amazon 下载 mysql-ssl-ca-cert.pem 文件(请参阅链接)。然后尝试使用该文件从终端进行连接。
Amazon 表示,您可以使用此 grant 语句限制与 SSL 的连接,因此请在连接时运行此语句。
现在断开连接并尝试在不使用“--ssl_ca=mysql-ssl-ca-cert.pem”标志的情况下再次连接。如果您被拒绝,那么您就知道该用户现在需要 SSL 连接。现在你只需要正确设置 php 即可。像这样的事情:
如果您可以连接,那么您已通过 SSL 连接,并且您可以运行 Tom 的查询来确认是否需要。
I know it's an old question, but I had this problem too and solved it so thought I would share my answer for posterity.
Amazon's docs are pretty helpful. First you need to download the mysql-ssl-ca-cert.pem file from Amazon (see the link). Then try to connect from the terminal using that file.
Amazon says that you can restrict a connection to SSL by using this grant statement, so run this statement while connected.
Now disconnect and try to connect again without the "--ssl_ca=mysql-ssl-ca-cert.pem" flag. If you are denied, then you know that SSL connections are now required for this user. Now you just need to setup php correctly. Something like this:
If you can connect then you are connected with SSL and you can run Tom's query to confirm if you want.