Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6381191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:21:53+00:00 2026-05-25T02:21:53+00:00

I am attempting to create a PHP SOAP connection to a .NET Web Service

  • 0

I am attempting to create a PHP SOAP connection to a .NET Web Service that has a self-signed certificate in order to lock down the service for communication over HTTPS. I continue to get error’s and I’m not sure if it has something to do with the way I create the certificate, my Apache/PHP setup, the way I attempt to establish the SOAP request or something else. If anyone has any pointers they will be greatly appreciated. Thanks in advance.

Certificate Generation

This is how I am creating the certificate.

  1. Create the trusted root private key:

    genrsa -out ca_authority_prv.pem 2048

  2. Create the trusted root authority cert:

    req -new -key ca_authority_prv.pem -x509 -out ca_authority_cert.pem

  3. Make the cert authority trusted:

    x509 -in ca_authority_cert.pem -out ca_authority_trust.pem -trustout

  4. Exit OpenSSL and create a serial file:

    echo 1000 > ca_authority.srl

  5. Create the client private key:

    genrsa -out Client_prv.pem 2048

  6. Create the client request:

    req -new -key Client_prv.pem -out Client_req.pem

  7. Sign the client request with the CA:

    x509 -req -CA ca_authority_trust.pem -CAserial ca_authority.srl -CAkey ca_authority_prv.pem -in Client_req.pem -out Client_cert.pem

  8. Make the pfx for the client cert

    pkcs12 -export -in Client_cert.pem -inkey Client_prv.pem -out Client_cert.pfx

IIS Setup

Once this certificate is created I follow the same steps for a server certificate and:

  1. Add the trusted root CA to the Machine Trusted Root Store

  2. Add the server certificate to the machine store

  3. Setup IIS to use the server certificate and require client certificates

PHP SOAP Request

This is the code I am using to establish the PHP SOAP request (below is the error):

$wsdl = "https://localhost/MyService/MyService.asmx";
$local_cert = "C:\\Certs\client_cert.pem";
$passphrase = "openSaysMe";

    $soapClient = new SoapClient($wsdl, array('local_cert'=>  $local_cert,'passphrase'=>$passphrase));
    $theResponse = $soapClient->test();

ERROR

Warning: SoapClient::SoapClient() [soapclient.soapclient]: Unable to set private key file `C:\Certs\client_cert.pem' in C:\Program Files\Apache Group\Apache2\htdocs\soapWithAuth.php on line 53

Warning: SoapClient::SoapClient() [soapclient.soapclient]: failed to create an SSL handle in C:\Program Files\Apache Group\Apache2\htdocs\soapWithAuth.php on line 53

Warning: SoapClient::SoapClient() [soapclient.soapclient]: Failed to enable crypto in C:\Program Files\Apache Group\Apache2\htdocs\soapWithAuth.php on line 53

Warning: SoapClient::SoapClient(https://localhost/MyService/MyService.asmx) [soapclient.soapclient]: failed to open stream: operation failed in C:\Program Files\Apache Group\Apache2\htdocs\soapWithAuth.php on line 53

Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "https://localhost/MyService/MyService.asmx" in C:\Program Files\Apache Group\Apache2\htdocs\soapWithAuth.php on line 53
Error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/MyService/MyService.asmx'

ERROR LOG

PHP Warning:  SoapClient::SoapClient() [<a href='soapclient.soapclient'>soapclient.soapclient</a>]: failed to create an SSL handle in C:\\Program Files\\Apache Group\\Apache2\\htdocs\\soapWithAuth.php on line 54
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:21:54+00:00Added an answer on May 25, 2026 at 2:21 am

    I managed to get this working but there are some oddities that I wonder about. Specifically the need to combine the client certificate and private key into a single file to send along with the Soap Request as well as the certificate pass-phrase was breaking the request although the PHP Soap documentation explicitly includes it as an option. If anyone has input on how to improve this I would love to hear it.

    1) Create the OpenSsl client and server certificates and sign them with the certificate authority. When creating the certificate do not assign a passphrase to them, just hit the enter button at that point.

    2) Import the server certificate authority file into the Machine certificate store under the trusted root. You can get to this by using the MMC command at the command prompt and then adding the Certificates snap in.

    3) Import the Server certificate into the Machine store Personal certificate store

    4) Import the client certificate in the local account Personal store. You can do this by typing certmgr.msc at the command prompt.

    5) Make sure to have Apache with a SSL version of PHP running. If you already had a non-php version of PHP installed you can follow these steps to configure your Apache server to run using SSL.

    Inside httpd.conff

    a) Remove the comment ‘#’ at line : LoadModule ssl_module modules/mod_ssl.so
    
    b) Remove the comment ‘#’ at the line inside `<IfModule ssl_module>`:  Include /extra/httpd-ssl.conf
    
       and move this line after the block `<IfModule ssl_module>…. </IfModule>`  
    

    Inside php.ini

    c) Remove the comment ‘;’ at the line which says: extension=php_openssl.dll
    

    6) Configure IIS to use a certificate and SSL using the following steps:

    a) Right click the 'Default Website' node choose 'Properties'
    
    b) 'Directory Security' tab 'Server Certificate' button. Follow the wizard to select the certificate you imported into the store then complete the wizard and return to the 'Directory Security' tab.
    
    c) Under 'Secure Communications' select the 'Edit' button. 
    
    d) Check the 'Require Secure Channel (SSL) checkbox.
    

    7) Creating the PHP SOAP request (the test() method should be a valid method in your Web service):

    $wsdl = "https://localhost/MyService/myservices.asmx?wsdl";
    $local_cert = "C:\\SoapCerts\ClientKeyAndCer.pem";
    
    $soapClient = new SoapClient($wsdl, array('local_cert' => $local_cert));
    
    $theResponse = $soapClient->test();
    

    8) Place this file into your Apache directory. By Default: ‘C:\Program Files\Apache Group\Apache2\htdocs’

    9) You will need access to the client certificate. In the steps you took to produce the client and server certificates you also produced the private key files. Open the client_prv.pem (the client private key file) and copy the contents into a new document with a text editor. It is probably safer to use something like Textpad that will hopefully not add a bunch of special characters, certificate parsers are very picky. Immediately after the private key part place the contents of the client certificate (client_cer.pem) so that the resulting file is an un-escaped copy of the client private key and client

    certificate. Save the resulting file to a directory you can get to from the php file. In the example above the resulting file is the

    ‘C:\SoapCerts\ClientKeyAndCer.pem’ file.

    9) Navigate to localhost/nameOfYourFile.php. You should see a successful connection to the service with a response matching the expected results from your

    Web service method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
I am attempting to create a web page that will allow a user to
I'm attempting to create a contacts application that has two main entities - person
I am attempting to create a php script that can connect thru ssh to
I am attempting to create a REST API in PHP and I'd like to
I am attempting to create a UPnP method on an internal PHP server if
I'm currently attempting to create a tabbed interface in a web application, and based
I am attempting to create new membership users in an Ektron CMS400.NET-based website by
I am attempting to create a very simple web interface for changing some system
I am attempting to create an effect on my website that once you hover

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.