473,395 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

fsockopen PHP5 missing 6th argument (context)

I've noticed that fsockopen (as of PHP 5) no longer accepts context.
How can I make an SSL connection (requiring a client cert) without
using curl?

Nov 22 '05 #1
1 5139
I've found the answer!

$certFile = './yourcert.pem';
$passPhrase = 'yourpassphrase';

$context = stream_context_create();
$result = stream_context_set_option($context, 'ssl', 'local_cert',
$certFile);
if($passPhrase)
$result = stream_context_set_option($context, 'ssl', 'passphrase',
$passPhrase);
$result = stream_context_set_option($context, 'ssl', 'verify_peer',
false);
$result = stream_context_set_option($context, 'ssl', 'verify_host',
false);
$result = stream_context_set_option($context, 'ssl',
'allow_self_signed', true);

$sock = stream_socket_client('ssl://www.somewhere.com:443',
&$errno,&$errstr, 60, STREAM_CLIENT_CONNECT, $context);

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Atarikid | last post by:
This script works fine on my redhat9 machine. I use it with Winblows PC I get an error. My site is not shown however it is a XML server accessible over simple HTTP post and get. The error is as...
1
by: Gil-Dale | last post by:
Trying to make a connection via a proxy to another site using the fsockopen I can get it hitting the proxy server just can't get it through. I have user name and password to get through the...
2
by: Colin Bell | last post by:
I'm stuck on a problem with getting data from a XML data stream. This stream is large and trying to use fsockopen to get the stream down. I've tetsed the code by telneting into the machine/port...
2
by: Loopy | last post by:
I'm trying to write a script that will connect to an external site so that I can get access referer information in a database on another one of my sites. I got errors, so I tried to write a script...
9
by: fipaj1992 | last post by:
Hi! I have very big problem with fsockopen() function. It is very important... That's code: <?php $test = fsockopen ('chrome.pl', '8080'); ?>
69
by: markarichman | last post by:
Why is Firefox complaining with this error: ------------------------------------------------------------ missing ) after argument list setTimeout('breakOut',5000);...
0
by: cypres | last post by:
I've installed a new linux fedora core 4 server with PHP5 and it had Plesk 8.0.1 as control panel (don't know if this is relevant). Everything is working fine but when I try to do a simple...
2
by: Alex | last post by:
Hi all, I'm having a problem with fsockopen function, I'm programming with php 4.3 and need to do an HTTP POST over secure socket, ssl, here's my code: $context = stream_context_create();...
4
by: MikeofPet | last post by:
I am trying to implement FTP in a PHP script but am unable to make the connection to the remote server. The connection step times out at the fsockopen function. I am not sure if it is relevant but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.