Php 不接受证书。无法设置私钥文件

Php 不接受证书。无法设置私钥文件,php,soap,certificate,pem,pfx,Php,Soap,Certificate,Pem,Pfx,我尝试通过SoapClient建立连接。我需要这方面的证书。我收到了.pfx证书。我使用以下命令创建了一个.pem文件 openssl pkcs12-in cert.pfx-out cert.pem-nodes 证书中有密码,因此我需要在获取cert.pem文件之前输入密码。我想,到目前为止还不错 现在我尝试连接到WSDL服务 $url = "https://test.website.com/webservices/transfer.asmx?WSDL"; $cert = '/path/to/

我尝试通过SoapClient建立连接。我需要这方面的证书。我收到了.pfx证书。我使用以下命令创建了一个.pem文件

openssl pkcs12-in cert.pfx-out cert.pem-nodes
证书中有密码,因此我需要在获取cert.pem文件之前输入密码。我想,到目前为止还不错

现在我尝试连接到WSDL服务

$url = "https://test.website.com/webservices/transfer.asmx?WSDL";
$cert = '/path/to/cert.pem';
$passphrase = "12345678";                                               

$soapClient = new SoapClient($url, array('local_cert'=>$cert,'passphrase'=>$passphrase));
我得到以下错误:

(警告)SoapClient::SoapClient():无法设置私钥文件“/var/www/vhosts/………/cert.pem”


我认为问题在于证书。我将.pfx转换为.pem的方法正确吗?

您遇到的问题是,
.pem
证书始终应该是加密文件。根据使用
-nodes
时的说明,它没有加密任何内容,而是将每个节点放入纯文本中,这导致
.pem
证书无效,并且您的
SoapClient
无法解析无效文件

要解决此问题,希望您没有删除原始的
cert.pfx
,只需使用以下行重新转换它:

openssl pkcs12 -in cert.pfx -out cert.pem -clcerts

而且您的
cert.pem
文件将是正确的。

我仍然有这个问题。找到这个。注意:此处包含“-nodes”标志将防止使用密码短语加密私钥。无论是否使用密码,我都会遇到同样的错误。该证书是公共证书还是私人证书?为什么使用
-nodes
而不是
-clcerts
?你是我今天最喜欢的人!泰!在尝试了一百零一种获得正确证书的方法后,这终于成功了。然后
$soapClient=new\soapClient($wsdl,['local_cert'=>'cert.pem','passphrase'=>'输入pem密码短语','trace'=>1,'exceptions'=>0])$soapClient->\uuu getFunctions()检索所有给定的方法