不接受证书。无法设置私钥文件
Certificate not accepted. Unable to set private key file
我尝试通过 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));
我收到以下错误:
(Warning) SoapClient::SoapClient(): Unable to set private key file `/var/www/vhosts/............./cert.pem'
我认为是证书的问题。我将 .pfx 转换为 .pem 的方式是否正确?
您 运行 遇到的问题是 .pem
证书始终应该是加密文件。根据 OpenSSL docs for the pkcs12 command 当您使用 -nodes
它没有加密任何东西,而是将每个节点放入纯文本,这导致 .pem
证书无效并且您的 SoapClient
无法解析无效文件。
要解决此问题,希望您没有删除原始 cert.pfx
,只需使用以下行重新转换它即可:
openssl pkcs12 -in cert.pfx -out cert.pem -clcerts
您的 cert.pem
文件将是正确的。
今天我遇到了无效 Cert/Private 组合的问题,这意味着证书不属于指定的密钥。
您可以使用以下方法验证此问题:
openssl rsa -noout -modulus -in server.key | openssl md5
openssl x509 -noout -modulus -in server.crt | openssl md5
密钥和证书应该return相同的校验和。如果不是,有人混淆了一些文件。
同样的程序也适用于 CSR:
# and for a CSR
openssl req -noout -modulus -in server.csr | openssl md5
我尝试通过 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));
我收到以下错误:
(Warning) SoapClient::SoapClient(): Unable to set private key file `/var/www/vhosts/............./cert.pem'
我认为是证书的问题。我将 .pfx 转换为 .pem 的方式是否正确?
您 运行 遇到的问题是 .pem
证书始终应该是加密文件。根据 OpenSSL docs for the pkcs12 command 当您使用 -nodes
它没有加密任何东西,而是将每个节点放入纯文本,这导致 .pem
证书无效并且您的 SoapClient
无法解析无效文件。
要解决此问题,希望您没有删除原始 cert.pfx
,只需使用以下行重新转换它即可:
openssl pkcs12 -in cert.pfx -out cert.pem -clcerts
您的 cert.pem
文件将是正确的。
今天我遇到了无效 Cert/Private 组合的问题,这意味着证书不属于指定的密钥。
您可以使用以下方法验证此问题:
openssl rsa -noout -modulus -in server.key | openssl md5
openssl x509 -noout -modulus -in server.crt | openssl md5
密钥和证书应该return相同的校验和。如果不是,有人混淆了一些文件。
同样的程序也适用于 CSR:
# and for a CSR
openssl req -noout -modulus -in server.csr | openssl md5