Encrypted web services connections and pk12 certificates

I need to do some code to talk to a SOAP web service. Unfortunately, I cannot connect to the service as it requires an SSL connection encrypted with a special certificate. I was given a pk12 certificate which when installed in my keychain allows me to access the SOAP service manually via Safari, but I cannot get a connection to the Cocoa web services :( Does anyone have any idea what I need what to do to make this work?

0


source to share


3 answers


I faced similar problems. Is this a self-signed certificate? If so, you may find that all you need to do is change the trust settings in that certificate.

There is another workaround where you say that this site should ignore trust settings, but that leaves you open to man-in-the-middle attacks. There is one more topic in this thread:



Objective-C / Cocoa How to Accept Bad Server Certificate?

0


source


Typically, you must submit the certificate as part of your code. For example, in C #, you need to specify a certificate like this:

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!

      

In PHP this would be:



   $cert = "myCert.pem"; //notice it in PEM format. 

   $client = new SoapClient($wsdl, array('local_cert' => $cert));

      

To make a PEM file from .p12 you can use:

OpenSSL> pkcs12 -in myCert.p12 -out myCert.pem -nodes -clcerts

0


source


-1


source







All Articles