【发布时间】:2019-01-15 18:26:56
【问题描述】:
我需要在邮递员中运行这个字符串
curl -i -X POST -H “SOAPAction: urn:nhs-itk:services:201005:getNHSNumber-v1-0” -H “content-type: text/xml” –E pem_filename.pem -d @getNHSNumber.xml -k https://someip/smsp/pds
当我使用原始数据导入 Postman 时,我收到此错误 导入 Curl 时出错:找到 4 个无选项参数。仅支持一个(URL)
我通过 VPN 连接,拥有 3 个证书和 1 个关键端点证书、端点颁发子 CA 证书、根 CA 证书和端点私钥,格式如下
您的端点私钥:
-----开始 RSA 私钥--
我的主要内容
-----结束 RSA 私钥-----
您的端点证书
-----BEGIN CERTIFICATE-----我的证书内容 -----结束证书-----
端点颁发 subCA 证书
-----BEGIN CERTIFICATE-----我的证书内容 -----END 证书-----
根 CA 证书
-----BEGIN CERTIFICATE-----我的证书内容 -----END 证书-----
现在,我通过将所有这些键复制到一个文件中,从所有这些键中创建了一个 pem 文件,并尝试在 php 和 postman 中使用。我在上面分享了 Postmam 错误。 PHP 代码错误是 Curl Error: could not load PEM client certificate, OpenSSL error error:0906D06C:PEM routines:PEM_read_bio:no start line, (no key found, wrong pass phrase, or wrong file format?)No HTTP code were returned
php代码
<?php
$url = "https://myip/smsp/pds";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$pemFile = tmpfile();
fwrite($pemFile, "abc.pem");//the path for the pem file
$tempPemPath = stream_get_meta_data($pemFile);
$tempPemPath = $tempPemPath['uri'];
curl_setopt($ch, CURLOPT_SSLCERT, $tempPemPath);
//curl_setopt($ch, CURLOPT_SSLCERT, "test.pem" );
curl_setopt($ch,CURLOPT_SSLCERTTYPE,"PEM");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
curl_setopt($ch, CURLOPT_POST, True);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$post = array(
"file" => "@" .realpath("getNHSNumber.xml")
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$result = curl_exec($ch);
if(!$result)
{
echo "Curl Error: " . curl_error($ch);
}
else
{
echo "Success: ". $result;
}
$info = curl_getinfo($ch);
curl_close($ch); // close cURL handler
?>
我的问题是 如何在 php 中运行它?在邮递员?我是否创建了正确的 pem 文件?
【问题讨论】: