【发布时间】:2008-12-08 03:20:20
【问题描述】:
我需要编写一些代码来与 SOAP Web 服务通信。不幸的是,我无法连接到该服务,因为它需要使用特殊证书加密的 SSL 连接。我已经获得了一个 pk12 证书,当它安装到我的钥匙串中时,我可以通过 Safari 手动访问 SOAP 服务,但我无法从 Cocoa Web 服务的东西获得连接:( 是否有人对我可能需要做些什么才能使其正常工作有任何想法?
【问题讨论】:
标签: cocoa soap encryption
我需要编写一些代码来与 SOAP Web 服务通信。不幸的是,我无法连接到该服务,因为它需要使用特殊证书加密的 SSL 连接。我已经获得了一个 pk12 证书,当它安装到我的钥匙串中时,我可以通过 Safari 手动访问 SOAP 服务,但我无法从 Cocoa Web 服务的东西获得连接:( 是否有人对我可能需要做些什么才能使其正常工作有任何想法?
【问题讨论】:
标签: cocoa soap encryption
我也遇到过类似的问题。这是自签名证书吗?如果是这样,您可能会发现您需要做的就是更改此证书上的信任设置。
还有另一种解决方法,您说该站点应忽略信任设置,但这会使您容易受到中间人攻击。关于这个主题还有另一个关于 SO 的帖子:
【讨论】:
通常,您必须将证书作为代码的一部分提供。例如,在 C# 中,您需要像这样指定证书:
using System.Security.Cryptography.X509Certificates;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//some code creating your soap client
string cert_file = "C:\\prf_res.pem"; //You'll probably use the PEM format here, not the .p12 format
X509Certificate cert = new X509Certificate(cert_file);
soap_client.ClientCertificates.Add(cert);
//now you're set!
在 PHP 中,它是:
$cert = "myCert.pem"; //notice it's in PEM format.
$client = new SoapClient($wsdl, array('local_cert' => $cert));
要使用 .p12 制作 PEM 文件,您可以使用:
OpenSSL> pkcs12 -in myCert.p12 -out myCert.pem -nodes -clcerts
【讨论】:
【讨论】: