4

i want to parse all kinds of ssl/https Sites.

E.g i want the content of https://microsoft.de, but it do not work. Following Erros appears:

    Fatal error: Uncaught exception 'ErrorException' with message 'stream_socket_enable_crypto() [<a href='function.stream-socket-enable-crypto'>function.stream-socket-enable-crypto</a>]: 
SSL operation failed with code 1. 
OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' 
in C:\Users\Privat\Desktop\Server\Apache2\htdocs\allsubmitter\server\vendor\zendframework\zend-http\Zend\Http\Client\Adapter\Socket.php:276 
Stack trace: #0 [internal function]: Zend\Stdlib\ErrorHandler::addError(2, 'stream_socket_e...', 'C:\Users\Privat...', 276, Array) #1 C:\Users\Privat\Desktop\Server\Apache2\htdocs\allsubmitter\server\vendor\zendframework\zend-http\Zend\Http\Client\Adapter\Socket.php(276): stream_socket_enable_crypto(Resource id #35, true, 2) 
#2 C:\Users\Privat\Desktop\Server\Apache2\htdocs\allsubmitter\server\vendor\zendframework\zend-http\Zend\Http\Client.php(1356): Zend\Http\Client\Adapter\Socket->connect('microsoft.de', 443, true) #3 C:\Users\Privat\Desktop\Server\Apache2\htdocs\ in C:\Users\Privat\Desktop\Server\Apache2\htdocs\allsubmitter\server\vendor\zendframework\zend-http\Zend\Http\Client\Adapter\Socket.php on line 299




$config = array(
        'adapter'      => 'Zend_Http_Client_Adapter_Socket',
        'ssltransport' => 'tls'
);
$client = new \Zend\Http\Client("https://microsoft.de");

1 Answer 1

3

You can tell the client not to verify the SSL, try this config:

$clientConfig = array(
    'adapter' => 'Zend\Http\Client\Adapter\Curl',
    'curloptions' => array(
        CURLOPT_FOLLOWLOCATION => TRUE,
        CURLOPT_SSL_VERIFYPEER => FALSE
    ),
);

$this->_client = new \Zend\Http\Client('https://microsoft.de', $clientConfig);
Sign up to request clarification or add additional context in comments.

3 Comments

I aslso think you are mixing ZF2 and ZF2 notation there, using underscores rather than namspaced class names.
why you mean i mixing zf2 and zf2. why zf2 and zf2 :D. And why you say i should use the "old" style with underscores rather than namespaced? Or do i dont understand you. and thank you very much. and why the hell your code is working like charm but not with the "default" fsocket?
you are using the old style underscores for your adapter, it needs to be namespaced like mine in ZF2. But using the curl adapter you can disable checking of SSL, you can do it via Socket too if you check the docs, glad it helped :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.