fsockopen PHP5 missing 6th argument (context)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • joel.washburn@gmail.com

    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?

  • joel.washburn@gmail.com

    #2
    Re: fsockopen PHP5 missing 6th argument (context)

    I've found the answer!

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

    $context = stream_context_ create();
    $result = stream_context_ set_option($con text, 'ssl', 'local_cert',
    $certFile);
    if($passPhrase)
    $result = stream_context_ set_option($con text, 'ssl', 'passphrase',
    $passPhrase);
    $result = stream_context_ set_option($con text, 'ssl', 'verify_peer',
    false);
    $result = stream_context_ set_option($con text, 'ssl', 'verify_host',
    false);
    $result = stream_context_ set_option($con text, 'ssl',
    'allow_self_sig ned', true);

    $sock = stream_socket_c lient('ssl://www.somewhere.c om:443',
    &$errno,&$errst r, 60, STREAM_CLIENT_C ONNECT, $context);

    Comment

    Working...