-1
我需要使用私人X509密鑰簽署xml數據類型 以下是我用過的代碼: $ data-> save(「test.xml」);使用私人X509密鑰簽名xml數據類型
$data = new DOMDocument("1.0", "utf-8");
$xml_order = $data->createElement("order");
$xml_tag1 = $data->createElement("signature","000");
$xml_tag2 = $data->createElement("service","000");
$xml_tag3 = $data->createElement("url");
$xml_tag_confirm = $data->createElement("confirm","yes");
$attr = $data->appendChild($xml_order);
$attr->appendChild($xml_tag1);
$attr->appendChild($xml_tag2);
$url = $attr->appendChild($xml_tag3);
$url->appendChild($xml_tag_confirm);
$attr->setAttribute("type","ama");
$attr->setAttribute("id", "passwordiguess");
$attr->setAttribute("date", date("YmdHis"));
$signature;
$pkeyid = openssl_pkey_get_private(file_get_contents('./private.key'));
$keyData = openssl_pkey_get_details($pkeyid);
openssl_sign($data, $signature, $pkeyid);
openssl_free_key($pkeyid);
它返回的錯誤是:
警告:openssl_sign()預計參數1是串,對象在C中給出:在線路32 \ XAMPP \ htdocs中\測試\的index.php
可以顯示$ data值! – M0ns1f
是的......更新了問題 –