使用PHP远程SSL连接到AWS(Keypairs)

时间:2017-11-20 20:18:07

标签: php amazon-web-services ssl

我正在尝试使用SSL连接到AWS RDS实例,但我一直收到此错误:

mysqli_real_connect():无法设置私钥文件

我正在做的是:

  1. 在AWS中生成密钥对,保留私钥。
  2. 使用OpenSSL使用此命令和我从AWS获得的私钥获取cert.pem: openssl req -newkey rsa:2048 -nodes -keyout private-key-generated-by-AWS.pem - x509 -days 365 -out certificate.pem
  3. 我从此网站下载了cacert.pem: https://curl.haxx.se/docs/caextract.html
  4. 这是我的代码:     

    $_SESSION["shopping_cart"][$number_of_items]=$_GET["product_id"];
    

    我很确定我没有正确设置我的私钥,但我不知道我做错了什么,有什么建议吗?谢谢!

1 个答案:

答案 0 :(得分:2)

AWS RDS使用服务器端身份验证,而不是客户端。设置SSL连接或在数据库或IAM users内配置的任何用户后,您需要输入主密码。

https://dev.mysql.com/doc/refman/5.6/en/using-encrypted-connections.html

可以在https://s3.amazonaws.com/rds-downloads/rds-ca-2015-root.pem

下载适用于所有地区的根证书

中间人在这里:https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html

mysql -h myinstance.c9akciq32.rds-us-east-1.amazonaws.com
--ssl-ca=[full path]rds-combined-ca-bundle.pem --ssl-verify-server-cert

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html#MySQL.Concepts.SSLSupport

相关问题