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 7721365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:54:24+00:00 2026-06-01T03:54:24+00:00

Background: In some PHP code dealing with a 3rd party web-service, the following code

  • 0

Background:

In some PHP code dealing with a 3rd party web-service, the following code works:

// connect to web-service
$remote_addr = "tcp://{$data['ip']}:{$data['port']}";
$socket = stream_socket_client($remote_addr, $errno, $errstr, 30);
if (!$socket) throw "Couldn't create socket: $errstr\n";

// configure SSL options on socket
stream_context_set_option($socket, 'ssl', 'local_cert', $data['cert']);
stream_context_set_option($socket, 'ssl', 'verify_peer', false);
stream_context_set_option($socket, 'ssl', 'allow_self_signed', true);
stream_context_set_option($socket, 'ssl', 'cafile', $data['cafile']);

// do SSL handshake
stream_set_blocking ($socket, true);
stream_socket_enable_crypto ($socket, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT);
stream_set_blocking ($socket, false);

//... start talking HTTP

We go on to wrap this PHP code in our own JSON-RPC web-service in order to call it from an in-house management system, written in Perl.

In profiling this “solution”, I’ve discovered that I could greatly improve performance by removing the Perl-PHP (via HTTP) indirection. I’ve tried porting the code to Perl but have had issues matching the SSL options.

I’m using the $ua->ssl_opts() method of LWP::UserAgent to pass the correct options down to Net::SSL (Crypt::SSLeay). I’ve been using strace to determine whether the certificates are being read, and it looks like they are. However, I’m not sure whether Net::SSL succeeds in reading the key from the PEM.

Question:

What specific $ua->ssl_opts() arguments do I need to match the behaviour of the PHP code?

Notes:

  • $data['cert'] is the full path to a PEM file containing
    • Our “client” certificate – issued by the 3rd party
    • Our non-encrypted (RSA) private key – issued by the 3rd party

  • $data['cafile'] is the full path to the self-signed signing certificate – issued by the 3rd party
  • I’m not looking for security advice about the plaintext nature of the private key.
  • 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-06-01T03:54:25+00:00Added an answer on June 1, 2026 at 3:54 am

    SSL pseudo-expert here. Going through your question and both docs, here’s what seems to have parity:

    1. 'local_cert'

      SSL_cert_file. From here.

    2. 'verify_peer'

      verify_hostname. From here and here, again.

    3. 'allow_self_signed'

      No parity. However, this option is moot, since you required verify_peer for that in the first place.

    4. 'cafile'

      SSL_ca_file. Also from here.

    You’ll also want to set SSL_version to support your need for SSLv3. And, that appears to be it.

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

Sidebar

Related Questions

Some background; I'm quite used to PHP, and I always used something like 'connect.ini'
I come from a PHP background and I'm just getting my teeth into some
I wrote some ajax code that sends values to a php file for validation
I'm have some php code: <? $cmd=mkfifo /tmp/myfifo;; system($cmd); $cmd=echo 1 > /tmp/myfifo 2>&1
So I am trying to execute some script from my php code. That lives
I'm having trouble getting some PHP code to work. Here is the function: function
We currently have some php code that allows an end user to update records
i'm trying to make some change in the following code which updates the number
Background: For some reason, whenever a user tries to open an xslx (excel 2007)
First some background: I'm working on an application and I'm trying to follow MVVM

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.