PDO SSL连接错误 [英] Error on PDO SSL connection

查看:100
本文介绍了PDO SSL连接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试从Windows框连接到Linux框时出现以下错误:

I am getting the following error when trying to connect from my Windows box to my Linux box:

Warning: PDO::__construct(): SSL operation failed with code 1. OpenSSL Error messages: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number

这是连接代码:

    $dbE = new PDO(
                    'mysql:dbname=db_name;host=host_ip;',
                    'username',
                    'password',
                    array(                                                                                     
                            PDO::MYSQL_ATTR_SSL_KEY         =>'client_side_path\client-key.pem',
                            PDO::MYSQL_ATTR_SSL_CERT        =>'client_side_path\client-cert.pem',
                            PDO::MYSQL_ATTR_SSL_CA          =>'client_side_path\ca-cert.pem'
                    )                                  
                   );
    $dbE->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    echo 'Connected';  

欢迎提出任何想法.

推荐答案

修复了该问题.原因是因为服务器B中到CA的路径不正确.值得注意的是,要解决此问题,我尝试直接从服务器A在PHP外部进行连接,结果出现错误其他签名确认不正确"-然后,我加载了CA证书,发现它为空.重新启动服务器,在my.cnf 服务器开始调用中设置正确的路径,并且所有路径都已固定.真的值得尝试mysql直接连接,因为它给出了一个非常不同的错误,它比PDO有用得多.

Fixed it. The reason was because the path in Server B to the CA was incorrect. Its worth noting that to fix this I tried a connection outside of PHP directly from server A and it came up with an error "bad other signature confirmation" - I then loaded the CA cert and found it was empty. Rebooted the server, set the correct paths in both my.cnf and the server start call and all fixed. Really worth trying the mysql direct connection as it gave a very different error which was much more useful than the PDO one.

这篇关于PDO SSL连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆